diff options
author | Roman Gräf <roman.graef@gmail.com> | 2018-06-13 17:40:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-13 17:40:45 +0200 |
commit | af04f81ea010fed2288db8a5ec46ab353586e944 (patch) | |
tree | b43257a9817dc49fa0726d9771bf316499b06211 /src/main/kotlin | |
parent | 16e4951fac7f6925f0ea34d9b23ee6c1b56f0355 (diff) | |
parent | bdea42b25e60bfadfd8069d6a3d0b802f00376ee (diff) | |
download | pluggabledino-af04f81ea010fed2288db8a5ec46ab353586e944.tar.gz pluggabledino-af04f81ea010fed2288db8a5ec46ab353586e944.tar.bz2 pluggabledino-af04f81ea010fed2288db8a5ec46ab353586e944.zip |
Merge pull request #8 from romangraef/feature-loststateScore
score und highscore in loststate
Diffstat (limited to 'src/main/kotlin')
5 files changed, 23 insertions, 2 deletions
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/assets.kt b/src/main/kotlin/de/romjaki/pluggabledino/assets.kt index 6a0e600..42d3016 100644 --- a/src/main/kotlin/de/romjaki/pluggabledino/assets.kt +++ b/src/main/kotlin/de/romjaki/pluggabledino/assets.kt @@ -26,3 +26,5 @@ val buttonImage = Image(TextureLoader.getTexture("PNG", FileInputStream("assets/ val groundline = Image(TextureLoader.getTexture("PNG", FileInputStream("assets/images/groundline.png"))) val cactusImg = Image(TextureLoader.getTexture("PNG", FileInputStream("assets/images/cactus.png"))) + +val BirdImg= Image(TextureLoader.getTexture("PNG", FileInputStream("assets/images/bird1.png")))
\ No newline at end of file diff --git a/src/main/kotlin/de/romjaki/pluggabledino/game/GameWorld.kt b/src/main/kotlin/de/romjaki/pluggabledino/game/GameWorld.kt index 21c0571..9c405f0 100644 --- a/src/main/kotlin/de/romjaki/pluggabledino/game/GameWorld.kt +++ b/src/main/kotlin/de/romjaki/pluggabledino/game/GameWorld.kt @@ -121,7 +121,7 @@ class GameWorld : ContactListener { if (delay < 0) { createCactus1() - delay = random.nextFloat() + rand(1, 3)-0.5f + delay = random.nextFloat() + rand(2, 3)-0.5f } cacti.forEach { diff --git a/src/main/kotlin/de/romjaki/pluggabledino/main.kt b/src/main/kotlin/de/romjaki/pluggabledino/main.kt index d92ba50..94d9444 100644 --- a/src/main/kotlin/de/romjaki/pluggabledino/main.kt +++ b/src/main/kotlin/de/romjaki/pluggabledino/main.kt @@ -26,6 +26,8 @@ const val MAINMENU = 1 const val SETTINGS = 3 const val GAME = 2 const val LOST = 4 +var lastscore = 0 +var highscore = 0 fun main(args: Array<String>) { PluginLoader.loadPlugins() diff --git a/src/main/kotlin/de/romjaki/pluggabledino/states/GameState.kt b/src/main/kotlin/de/romjaki/pluggabledino/states/GameState.kt index 7ac5fa1..7ac2aa9 100644 --- a/src/main/kotlin/de/romjaki/pluggabledino/states/GameState.kt +++ b/src/main/kotlin/de/romjaki/pluggabledino/states/GameState.kt @@ -16,7 +16,7 @@ class GameState : BasicGameState() { override fun enter(container: GameContainer?, game: StateBasedGame?) { world = GameWorld() count = 0 - } +} override fun update(container: GameContainer?, game: StateBasedGame?, delta: Int) { count += delta @@ -24,6 +24,12 @@ class GameState : BasicGameState() { world = GameWorld() } if (world.hurt) { + lastscore = count / 100 + if(lastscore > highscore){ + + highscore = lastscore + + } game!!.enterState(LOST) } world.update(delta / 1000f, container.input) diff --git a/src/main/kotlin/de/romjaki/pluggabledino/states/LostState.kt b/src/main/kotlin/de/romjaki/pluggabledino/states/LostState.kt index 20ccf96..cec408c 100644 --- a/src/main/kotlin/de/romjaki/pluggabledino/states/LostState.kt +++ b/src/main/kotlin/de/romjaki/pluggabledino/states/LostState.kt @@ -34,6 +34,17 @@ class LostState : BasicGameState() { g!! g.scale(WIDTH_RATIO, HEIGHT_RATIO) g.background = Color.lightGray + g.drawStringCentered(lastscore.toString(), WIDTH / 2f, HEIGHT /2f ) + g.drawStringCentered("Score:", WIDTH / 2f , HEIGHT / 2f - 40f ) + if(lastscore > highscore ) { + g.drawStringCentered("NEUER HIGHSCORE:" + highscore, WIDTH / 2f, HEIGHT / 2f - 70f) + } + else { + + g.drawStringCentered("Highscore:" + highscore, WIDTH / 2f, HEIGHT / 2f - 70f) + + } + back.draw(g) playAgain.draw(g) } |