Skip to content
Snippets Groups Projects
Commit 4deb4123 authored by Salonen Matteus Elmeri's avatar Salonen Matteus Elmeri
Browse files

Lisätty pistelaskurit

parent 309190c0
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@ using System.Collections.Generic;
using Jypeli;
using Jypeli.Assets;
using Jypeli.Controls;
using Jypeli.Effects;
using Jypeli.Widgets;
namespace HyttysPeli;
......@@ -15,15 +16,19 @@ namespace HyttysPeli;
public class HyttysPeli : PhysicsGame
{
Image taustaKuva = LoadImage("taustakuva");
private IntMeter pistelaskuri;
private IntMeter helttilaskuri;
public override void Begin()
{
MasterVolume = 0.05;
SetWindowSize(1920, 1080, true);
Level.Background.Image = taustaKuva;
LuoPistelaskuri();
LuoHelttilaskuri();
BoundingRectangle alaosa = new BoundingRectangle(new Vector(-100, 1), Level.BoundingRect.BottomRight);
BoundingRectangle ylaosa = new BoundingRectangle(new Vector(-960, 0), new Vector(960, 540));
BoundingRectangle alaosa = new BoundingRectangle(new Vector(Level.Left, 0), Level.BoundingRect.BottomRight);
BoundingRectangle ylaosa = new BoundingRectangle(Level.BoundingRect.TopLeft, new Vector(Level.Right, 0));
Level.CreateBorders();
PhysicsObject pelaaja = new PhysicsObject(25, 100, Shape.Rectangle);
pelaaja.Position = RandomGen.NextVector(alaosa);
......@@ -68,6 +73,7 @@ public class HyttysPeli : PhysicsGame
rajahdys.UseShockWave = false;
this.Add(rajahdys);
Remove(hyttynen);
pistelaskuri.Value += 1;
}
......@@ -79,8 +85,13 @@ public class HyttysPeli : PhysicsGame
/// <param name="ampiainen">ampiainen johon pelaaja törmäsi</param>
private void PelaajaTormasiAmpiaiseen(PhysicsObject pelaaja, PhysicsObject ampiainen)
{
ClearAll();
Begin();
Remove(ampiainen);
helttilaskuri.Value -= 1;
if (helttilaskuri.Value == 0)
{
ClearAll();
Begin();
}
}
......@@ -139,4 +150,39 @@ public class HyttysPeli : PhysicsGame
peli.Add(ampiainen);
return ampiainen;
}
void LuoPistelaskuri()
{
pistelaskuri = new IntMeter(0);
Label pistenaytto = new Label();
pistenaytto.X = Screen.Left + 100;
pistenaytto.Y = Screen.Top - 100;
pistenaytto.TextColor = Color.Black;
pistenaytto.Color = Color.White;
pistenaytto.Title = "Pisteitä: ";
pistenaytto.BindTo(pistelaskuri);
Add(pistenaytto);
}
void LuoHelttilaskuri()
{
helttilaskuri = new IntMeter(3);
Label helttinaytto = new Label();
helttinaytto.X = Screen.Right - 100;
helttinaytto.Y = Screen.Top - 100;
helttinaytto.TextColor = Color.Black;
helttinaytto.Color = Color.Red;
helttinaytto.Title = "Elämät: ";
helttinaytto.BindTo(helttilaskuri);
Add(helttinaytto);
}
}
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