diff --git a/theGame/Game.cs b/theGame/Game.cs index 319458b..006d4be 100644 --- a/theGame/Game.cs +++ b/theGame/Game.cs @@ -60,13 +60,28 @@ namespace theGame } - public void DoMoves() - { - for (int i = 0; i < rocks.Count; i++) - { - rocks[i].positionX--; - } - - } + public void DoMoves() + { + for (int i = 0; i < rocks.Count; i++) + { + rocks[i].positionX--; + } + + int deleted_rock_index = -1; + + for (int i = 0; i < rocks.Count; i++) + { + if (rocks[i].positionX == playerCraft.positionX && rocks[i].positionY == playerCraft.positionY) + { + deleted_rock_index = i; + playerCraft.Health = playerCraft.Health - 15; + } + } + + if (deleted_rock_index >= 0) + { + rocks.RemoveAt(deleted_rock_index); + } + } } }