Commit f5866cd3 authored by Daniel Drießen's avatar Daniel Drießen

Bug fix shields didn't delete enemies

Bug fix touch sometimes didn't resume the Game
parent 7134e73a
......@@ -59,9 +59,9 @@ class Game(@Transient private val gameActivity: GameActivity, val options: GameO
if (player.intersects(Path().apply {
addRect(
event.x,
event.y - Constants.playerOffset.y,
event.y + Constants.playerOffset.y,
event.x + 1,
event.y + 1 - Constants.playerOffset.y,
event.y + 1 + Constants.playerOffset.y,
Path.Direction.CW
)
})) {
......
......@@ -53,7 +53,8 @@ class Player(pm: PathManager) : Sprite(pm) {
fun isOnPath(): Boolean {
val unified = Path()
for (path in pm.getPaths()) unified.addPath(path)
shields.removeAll { !(it.contains(unified)) }
if (pm.game.options.difficulty.diffRes < Constants.Difficulty.HARD.diffRes)
shields.removeAll { !(it.contains(unified)) }
return contains(unified)
}
......@@ -69,15 +70,15 @@ class Player(pm: PathManager) : Sprite(pm) {
for (sh in shields) {
sh.transform(Matrix().apply { setRotate(pm.game.speed, pos.x, pos.y) })
}
if (pm.game.options.difficulty.diffRes < Constants.Difficulty.HARD.diffRes) {
var rs: Shields? = null
for (sh in shields)
for (e in pm.getEnemies())
if (sh.intersects(e)) {
pm.removeEnemy(e)
rs = sh
}
shields.remove(rs)
}
var rs: Shields? = null
for (sh in shields)
for (e in pm.getEnemies())
if (sh.intersects(e)) {
pm.removeEnemy(e)
rs = sh
}
shields.remove(rs)
}
}
......@@ -59,8 +59,8 @@ class PathManager(val game: Game) : Serializable {
val upper = paths.last().end
paths.add(
when (if (paths.last() is RectPath) (0..3).random() else 0) {
0 -> RectPath(this, 200f, 400f, PointF(upper.x, upper.y - 75))
1 -> ArcPath(this, 200f, 600f, PointF(upper.x, upper.y - 200), (0..1).random() == 0)
0 -> RectPath(this, Constants.playerRadius*4.2f, 400f, PointF(upper.x, upper.y - 75))
1 -> ArcPath(this, Constants.playerRadius*4.2f, 600f, PointF(upper.x, upper.y - 200), (0..1).random() == 0)
2 -> CirclePath(this, PointF(upper.x, upper.y - 200), 300f, (0..4).random())
3 -> ForkPath(this, PointF(upper.x, upper.y - 250), 800, 200, 200)
else -> throw IllegalStateException()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment