Skip to content
Snippets Groups Projects
Commit 5a8330ef authored by Yli-Tainio Janne Sakri Juhani's avatar Yli-Tainio Janne Sakri Juhani
Browse files

pikkeihin voi kuolla

parent 5117afea
No related branches found
No related tags found
No related merge requests found
......@@ -90,7 +90,7 @@
<workItem from="1697975844304" duration="9893000" />
<workItem from="1698002748003" duration="5266000" />
<workItem from="1698053833135" duration="8530000" />
<workItem from="1698075901222" duration="2693000" />
<workItem from="1698075901222" duration="4348000" />
</task>
<servers />
</component>
......
......@@ -14,9 +14,9 @@ namespace Kolikkogoblin;
public class Kolikkogoblin : PhysicsGame
{
private static readonly String[] lines = {
" p ",
" EP ",
" ",
" * m ",
" * M ",
" X * * XXXX",
" XX X ",
" X ",
......@@ -30,7 +30,7 @@ public class Kolikkogoblin : PhysicsGame
" * X ",
" XXX X ",
" X ",
" wwww g ",
" WWWW G ",
};
private static readonly int TileWidth = 800 / lines[0].Length;
......@@ -47,10 +47,11 @@ public class Kolikkogoblin : PhysicsGame
tiles.SetTileMethod('X', LuoPalikka, Color.Wheat);
tiles.SetTileMethod('*', LuoKolikko, Color.Yellow);
tiles.SetTileMethod('g', LuoGoblin, Color.Green);
tiles.SetTileMethod('w', LuoPiikkeja, Color.DarkGray);
tiles.SetTileMethod('m', LuoMaali, Color.Blue);
tiles.SetTileMethod('p', LuoPistelaskuri, Color.Blue);
tiles.SetTileMethod('G', LuoGoblin, Color.Green);
tiles.SetTileMethod('W', LuoPiikkeja, Color.DarkGray);
tiles.SetTileMethod('M', LuoMaali, Color.Blue);
tiles.SetTileMethod('P', LuoPistelaskuri, Color.Blue);
tiles.SetTileMethod('E', LuoElamaLaskuri, Color.Blue);
tiles.Execute(TileWidth, TileHeight);
......@@ -108,6 +109,7 @@ public class Kolikkogoblin : PhysicsGame
AddCollisionHandler<PlatformCharacter, PhysicsObject>(goblin, LoytaaKolikon);
AddCollisionHandler<PlatformCharacter, PhysicsObject>(goblin, LoytaaPortaalin);
AddCollisionHandler<PlatformCharacter, PhysicsObject>(goblin, OsuuPiikkeihin);
void PelaajaHyppaa(Vector vektori)
{
......@@ -150,6 +152,19 @@ public class Kolikkogoblin : PhysicsGame
}
}
}
private void OsuuPiikkeihin(PlatformCharacter goblin, PhysicsObject kohde)
{
if (kohde.Tag.ToString() == "piikkeja")
{
Elamat.Value -= 1;
if (Elamat.Value == 0)
{
MessageDisplay.Add("Kuolit");
Remove(goblin);
}
}
}
private void LuoPiikkeja(Vector paikka, double leveys, double korkeus, Color vari)
{
......@@ -188,7 +203,7 @@ public class Kolikkogoblin : PhysicsGame
}
Label pistenaytto = new Label();
pistenaytto.X = Screen.Left + 100;
pistenaytto.X = Screen.Left + 60;
pistenaytto.Y = Screen.Top - 100;
pistenaytto.TextColor = Color.Black;
pistenaytto.Color = Color.Silver;
......@@ -197,5 +212,23 @@ public class Kolikkogoblin : PhysicsGame
pistenaytto.BindTo(KeratytKolikot);
Add(pistenaytto);
}
private IntMeter Elamat;
private void LuoElamaLaskuri(Vector paikka, double leveys, double korkeus, Color vari)
{
Elamat = new IntMeter(3);
Label elamat = new Label();
elamat.X = Screen.Left + 160;
elamat.Y = Screen.Top - 100;
elamat.TextColor = Color.Black;
elamat.Color = Color.Silver;
elamat.Title = "Elämät:";
elamat.BindTo(Elamat);
Add(elamat);
}
}
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