Przeglądaj źródła

Resets player position at the start of a new level. Closes #12

Sacha Ligthert 2 lat temu
rodzic
commit
1542837738
2 zmienionych plików z 12 dodań i 5 usunięć
  1. 7 5
      game.go
  2. 5 0
      player.go

+ 7 - 5
game.go

@@ -86,17 +86,19 @@ func (game *Game) gameDirector() {
 		// Clean the screen
 		game.screen.Clear()
 
-		// Draw starter conditions
-		game.drawBox()
-		game.drawPlayer()
-		//game.drawCoords()
-
 		// Draw robots??
 		if len(game.robots) == 0 {
 			game.level++
 			game.cleanTrash()
+			game.resetPlayer()
 			game.initRobots()
 		}
+
+		// Draw starter conditions
+		game.drawBox()
+		game.drawPlayer()
+		//game.drawCoords()
+
 		game.drawRobots()
 
 		// Draw my ex-wife

+ 5 - 0
player.go

@@ -119,3 +119,8 @@ func (game *Game) onPlayer(pos Position) bool {
 	}
 	return onPlayer
 }
+
+func (game *Game) resetPlayer() {
+	game.player.position.x = 40
+	game.player.position.y = 12
+}