Skip to content
Snippets Groups Projects
Commit 32720de8 authored by Kopperoinen Paulus's avatar Kopperoinen Paulus
Browse files

Jos mato kuolee, peli alkaa automaattisesti alusta

parent f420330f
No related branches found
No related tags found
No related merge requests found
......@@ -40,7 +40,6 @@ public class matopeli : PhysicsGame
private Objektit Omena;
private Objektit MatoMuu;
private Timer aikalaskuri;
public IntMeter pistelaskuri;
public List<Vector> MatoSijainti = new List<Vector>();
......@@ -64,19 +63,17 @@ public class matopeli : PhysicsGame
private bool GameOver;
private bool OmenaKentalla = true;
private bool OmenaKentalla;
public override void Begin()
{
Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli");
ClearAll();
AloitaUusiPeli();
}
public void AloitaUusiPeli()
{
MatoKeho.Clear();
MatoSijainti.Clear();
ClearAll();
Asetukset();
TileMap tiles = TileMap.FromStringArray(tasonkuva);
tiles['#'] = LuoSeina;
......@@ -123,11 +120,12 @@ public class matopeli : PhysicsGame
Nopeus = 0.1;
MatoLiikkunut = true;
GameOver= false;
OmenaKentalla = true;
}
private void MatoKuolee()
{
GameOver = true;
AloitaUusiPeli();
}
private PhysicsObject LuoMato()
{
......@@ -304,8 +302,12 @@ public class matopeli : PhysicsGame
{
Timer aikalaskuri = new Timer();
aikalaskuri.Interval=Nopeus;
aikalaskuri.Start();
aikalaskuri.Timeout += PaivitaKentta;
if (GameOver == false)
{
aikalaskuri.Start();
aikalaskuri.Timeout += PaivitaKentta;
}
}
/// <summary>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment