add collision with enemies
This commit is contained in:
parent
b860968ef5
commit
7eb109cf92
19
cart.wren
19
cart.wren
|
@ -326,15 +326,24 @@ class World {
|
||||||
i = i + 1
|
i = i + 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_player.alive) {
|
if (_player.alive) {
|
||||||
if (!(fgCheck(_player.x - _player.bw / 2, _player.y - _player.bh / 2) &&
|
var bx = _player.x - _player.bw / 2
|
||||||
fgCheck(_player.x - _player.bw / 2, _player.y + _player.bh / 2) &&
|
var by = _player.y - _player.bh / 2
|
||||||
fgCheck(_player.x + _player.bw / 2, _player.y + _player.bh / 2) &&
|
if (!(fgCheck(bx, by) &&
|
||||||
fgCheck(_player.x + _player.bw / 2, _player.y - _player.bh / 2))) {
|
fgCheck(bx, by + _player.bh) &&
|
||||||
//System.print("collision with foreground")
|
fgCheck(bx + _player.bw, by + _player.bh) &&
|
||||||
|
fgCheck(bx + _player.bw, by))) {
|
||||||
_player.die()
|
_player.die()
|
||||||
_vfx.add(Explosion.new(_player.x, _player.y))
|
_vfx.add(Explosion.new(_player.x, _player.y))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (e in _enemies) {
|
||||||
|
if (collide(bx, by, _player.bw, _player.bh, e.x, e.y, e.w, e.h)) {
|
||||||
|
_player.die()
|
||||||
|
_vfx.add(Explosion.new(_player.x, _player.y))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue