Add text for game over and get ready
This commit is contained in:
parent
714681e044
commit
898998e48a
43
index.html
43
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 @@
|
||||
">
|
||||
</div>
|
||||
|
||||
<div id="game_over" style="
|
||||
left:200px;
|
||||
top:200px;
|
||||
background-image:url(sheet.png);
|
||||
background-position: -0px -835px;
|
||||
width: 412px;
|
||||
height: 78px;
|
||||
z-index: 1;
|
||||
">
|
||||
</div>
|
||||
|
||||
<div id="get_ready" style="
|
||||
left:200px;
|
||||
top:200px;
|
||||
background-image:url(sheet.png);
|
||||
background-position: -0px -913px;
|
||||
width: 400px;
|
||||
height: 73px;
|
||||
z-index: 1;
|
||||
">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user