소스 검색

Change game-logic a bit. Reduces trash. Addresses #3 and #11.

Sacha Ligthert 2 년 전
부모
커밋
2c7c17e727
1개의 변경된 파일14개의 추가작업 그리고 7개의 파일을 삭제
  1. 14 7
      robots.go

+ 14 - 7
robots.go

@@ -43,21 +43,28 @@ func (game *Game) moveRobots() {
 	// After all the moves, lets check if any of the rowboz collided with anything
 	for i, r := range game.robots {
 
-		// Check if it collides with anything.
+		// Hit a player? Game over
 		if game.onPlayer(r) {
 			game.gameover = 1
 			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)
 
-			// create trash
-			game.addTrash(trash)
+			// Create trash
+			game.addTrash(r)
+
+		}
+
+		// Colided with Trash
+		if game.onTrash(r) {
+
+			// Delete robot
+			game.deleteRobot(i)
 
 		}