diff options
author | romangraef <romangraef@loves.dicksinhisan.us> | 2018-08-05 19:37:41 +0200 |
---|---|---|
committer | romangraef <romangraef@loves.dicksinhisan.us> | 2018-08-05 19:37:41 +0200 |
commit | 558dd3b92818566976043f750c4b3f2f34f2d17f (patch) | |
tree | 28b74f4e5133db0e1f12cb9432ed36c00ad306ce | |
parent | 6585706c47343bcaf8145d19e4eee2f23562ec57 (diff) | |
download | pluggabledino-558dd3b92818566976043f750c4b3f2f34f2d17f.tar.gz pluggabledino-558dd3b92818566976043f750c4b3f2f34f2d17f.tar.bz2 pluggabledino-558dd3b92818566976043f750c4b3f2f34f2d17f.zip |
IMPORTANT GAME UPDATE! NOW WITH 100% MORE COMMUNISM
-rw-r--r-- | src/main/kotlin/de/romjaki/pluggabledino/assets.kt | 9 | ||||
-rw-r--r-- | src/main/kotlin/de/romjaki/pluggabledino/game/GameWorld.kt | 16 | ||||
-rw-r--r-- | src/main/kotlin/de/romjaki/pluggabledino/states/GameState.kt | 5 | ||||
-rw-r--r-- | src/main/resources/audio/anthem.ogg | bin | 0 -> 4435152 bytes |
4 files changed, 12 insertions, 18 deletions
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/assets.kt b/src/main/kotlin/de/romjaki/pluggabledino/assets.kt index 42d3016..5c12b35 100644 --- a/src/main/kotlin/de/romjaki/pluggabledino/assets.kt +++ b/src/main/kotlin/de/romjaki/pluggabledino/assets.kt @@ -1,9 +1,6 @@ package de.romjaki.pluggabledino -import org.newdawn.slick.Animation -import org.newdawn.slick.Image -import org.newdawn.slick.SpriteSheet -import org.newdawn.slick.UnicodeFont +import org.newdawn.slick.* import org.newdawn.slick.opengl.TextureLoader import java.awt.Font import java.io.FileInputStream @@ -27,4 +24,6 @@ val groundline = Image(TextureLoader.getTexture("PNG", FileInputStream("assets/i 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 +val BirdImg = Image(TextureLoader.getTexture("PNG", FileInputStream("assets/images/bird1.png"))) + +val anthemSound = Music(FileInputStream("assets/audio/anthem.ogg"), "anthem.ogg") diff --git a/src/main/kotlin/de/romjaki/pluggabledino/game/GameWorld.kt b/src/main/kotlin/de/romjaki/pluggabledino/game/GameWorld.kt index 87b7a2c..3775faa 100644 --- a/src/main/kotlin/de/romjaki/pluggabledino/game/GameWorld.kt +++ b/src/main/kotlin/de/romjaki/pluggabledino/game/GameWorld.kt @@ -1,7 +1,6 @@ package de.romjaki.pluggabledino.game - import org.jbox2d.callbacks.ContactImpulse import org.jbox2d.callbacks.ContactListener import org.jbox2d.collision.Manifold @@ -23,10 +22,8 @@ class GameWorld : ContactListener { if (bodies.contains(dino) && cacti.any { bodies.contains(it) }) { hurt = true - } - else if (bodies.contains(dino) && birdd.any { bodies.contains(it) }) { + } else if (bodies.contains(dino) && birdd.any { bodies.contains(it) }) { hurt = true - } } @@ -108,16 +105,11 @@ class GameWorld : ContactListener { } - - - - fun rand(from: Int, to: Int): Int { return random.nextInt(to - from) + from } - fun createBird1(){ - + fun createBird1() { val body = world.createBody(birddBodyDef) @@ -136,8 +128,6 @@ class GameWorld : ContactListener { } - - fun createCactus1() { val body = world.createBody(cactiBodyDef) @@ -175,7 +165,7 @@ class GameWorld : ContactListener { createBird1() - bg = random.nextFloat() + rand(1, 2) + bg = random.nextFloat() + rand(1, 2) } cacti.forEach { it.linearVelocity.set(-delta * speed, 0f) diff --git a/src/main/kotlin/de/romjaki/pluggabledino/states/GameState.kt b/src/main/kotlin/de/romjaki/pluggabledino/states/GameState.kt index 6e538b5..fd868a9 100644 --- a/src/main/kotlin/de/romjaki/pluggabledino/states/GameState.kt +++ b/src/main/kotlin/de/romjaki/pluggabledino/states/GameState.kt @@ -19,9 +19,14 @@ class GameState : BasicGameState() { override fun enter(container: GameContainer?, game: StateBasedGame?) { world = GameWorld() + anthemSound.loop() count = 0 } + override fun leave(container: GameContainer?, game: StateBasedGame?) { + anthemSound.pause() + } + override fun update(container: GameContainer?, game: StateBasedGame?, delta: Int) { game!! count += delta diff --git a/src/main/resources/audio/anthem.ogg b/src/main/resources/audio/anthem.ogg Binary files differnew file mode 100644 index 0000000..8fa5727 --- /dev/null +++ b/src/main/resources/audio/anthem.ogg |