diff options
author | romangraef <roman.graef@gmail.com> | 2018-05-30 12:45:21 +0200 |
---|---|---|
committer | romangraef <roman.graef@gmail.com> | 2018-05-30 12:45:21 +0200 |
commit | 5a66413d8f226c0507788e5c8455f6f5f6d06887 (patch) | |
tree | 1187c7f83621f29364dc90f3aed1885d04dac42c /src/main/kotlin/de/romjaki/pluggabledino/states/GameState.kt | |
parent | 2ac18d91635b023db7ff3918f5041cb51ed1c968 (diff) | |
download | pluggabledino-5a66413d8f226c0507788e5c8455f6f5f6d06887.tar.gz pluggabledino-5a66413d8f226c0507788e5c8455f6f5f6d06887.tar.bz2 pluggabledino-5a66413d8f226c0507788e5c8455f6f5f6d06887.zip |
Added lost state/losing
Diffstat (limited to 'src/main/kotlin/de/romjaki/pluggabledino/states/GameState.kt')
-rw-r--r-- | src/main/kotlin/de/romjaki/pluggabledino/states/GameState.kt | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/states/GameState.kt b/src/main/kotlin/de/romjaki/pluggabledino/states/GameState.kt index 479f7f7..0d4fff0 100644 --- a/src/main/kotlin/de/romjaki/pluggabledino/states/GameState.kt +++ b/src/main/kotlin/de/romjaki/pluggabledino/states/GameState.kt @@ -21,6 +21,9 @@ class GameState : BasicGameState() { if (container!!.input.isKeyDown(Input.KEY_R)) { world = GameWorld() } + if (world.hurt) { + game!!.enterState(LOST) + } world.update(delta / 1000f, container.input) dinoAnimated.update(delta.toLong()) } @@ -34,11 +37,14 @@ class GameState : BasicGameState() { override fun render(container: GameContainer?, game: StateBasedGame?, g: Graphics?) { g!! g.background = Color.lightGray - g.color = Color.red + if (world.hurt) { + g.background = Color.red + } + g.color = Color.green g.drawImage(dinoAnimated.currentFrame, world.dino.position.x * WIDTH / 50, world.dino.position.y * HEIGHT / 50 - dinoAnimated.height) g.drawImage(groundline, 0f, HEIGHT * 39 / 50f) for (cactus in world.cacti) { - g.drawImage(cactusImg, cactus.position.x, cactus.position.y) + g.drawImage(cactusImg, cactus.position.x * WIDTH / 50, cactus.position.y * HEIGHT / 50 - cactusImg.height) } } |