From 79f63500e90199c44c4f0bc635b4476ccf069b41 Mon Sep 17 00:00:00 2001 From: Tyrannova Date: Sun, 13 Jan 2019 11:11:25 +0100 Subject: Fixed: remove offscreen cacti from list --- src/main/kotlin/de/romjaki/pluggabledino/game/GameWorld.kt | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/main/kotlin/de/romjaki/pluggabledino') diff --git a/src/main/kotlin/de/romjaki/pluggabledino/game/GameWorld.kt b/src/main/kotlin/de/romjaki/pluggabledino/game/GameWorld.kt index 3775faa..3375c92 100644 --- a/src/main/kotlin/de/romjaki/pluggabledino/game/GameWorld.kt +++ b/src/main/kotlin/de/romjaki/pluggabledino/game/GameWorld.kt @@ -170,9 +170,16 @@ class GameWorld : ContactListener { cacti.forEach { it.linearVelocity.set(-delta * speed, 0f) } + cacti.removeIf { + it.position.x < 0 + } + birdd.forEach { it.linearVelocity.set(-delta * speed, 0f) } + cacti.removeIf { + it.position.x < 0 + } world.step(delta, 4, 3) world.setContactListener(this) -- cgit