diff --git a/index.html b/index.html index fb5aed8..36c2701 100644 --- a/index.html +++ b/index.html @@ -90,6 +90,7 @@ }; var current_gamestate = GameState.STARTSCREEN; + var has_died = false; function frame() { @@ -139,6 +140,12 @@ player.position_y += player.velocity_y * dt; player.position_x += 100 * dt; + // Clamp at top + if (player.position_y < 0) { + player.position_y = 0; + player.velocity_y = 0; + } + // Gravity player.velocity_y += GRAVITY * dt; @@ -157,11 +164,25 @@ top: player.position_y + "px", left: player.position_x + "px" }); + + if (current_gamestate == GameState.STARTSCREEN) { + if (has_died == false) { + $("#get_ready").css({ visibility: "visible" }); + $("#game_over").css({ visibility: "hidden" }); + } else { + $("#get_ready").css({ visibility: "hidden" }); + $("#game_over").css({ visibility: "visible" }); + } + } else { + $("#get_ready").css({ visibility: "hidden" }); + $("#game_over").css({ visibility: "hidden" }); + } } function die() { current_gamestate = GameState.STARTSCREEN; + has_died = true; } function restart() { @@ -234,6 +255,28 @@ "> +