Browse Source

add simple crash logic

master
parent
commit
efd01c6586
  1. 31
      theGame/Game.cs

31
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);
}
}
}
}

Loading…
Cancel
Save