parent
f0ad3157f3
commit
2c7c17e727
21
robots.go
21
robots.go
@ -43,21 +43,28 @@ func (game *Game) moveRobots() {
|
|||||||
// After all the moves, lets check if any of the rowboz collided with anything
|
// After all the moves, lets check if any of the rowboz collided with anything
|
||||||
for i, r := range game.robots {
|
for i, r := range game.robots {
|
||||||
|
|
||||||
// Check if it collides with anything.
|
// Hit a player? Game over
|
||||||
if game.onPlayer(r) {
|
if game.onPlayer(r) {
|
||||||
game.gameover = 1
|
game.gameover = 1
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if game.onRobot(i, r) || game.onTrash(r) {
|
// Robots mingling? Trash
|
||||||
|
if game.onRobot(i, r) {
|
||||||
|
|
||||||
trash := r
|
// Delete robot
|
||||||
|
|
||||||
// delete robot
|
|
||||||
game.deleteRobot(i)
|
game.deleteRobot(i)
|
||||||
|
|
||||||
// create trash
|
// Create trash
|
||||||
game.addTrash(trash)
|
game.addTrash(r)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Colided with Trash
|
||||||
|
if game.onTrash(r) {
|
||||||
|
|
||||||
|
// Delete robot
|
||||||
|
game.deleteRobot(i)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user