Skip to content
Snippets Groups Projects
Commit c040d372 authored by Vesa Lappalainen's avatar Vesa Lappalainen :bicyclist:
Browse files

pong poistetaan loputkin attribuutit

parent 32f7219c
No related branches found
No related tags found
No related merge requests found
......@@ -8,24 +8,20 @@ public class Pong : PhysicsGame
private readonly Vector nopeusYlos = new Vector(0, 200);
private readonly Vector nopeusAlas = new Vector(0, -200);
private PhysicsObject pallo;
private PhysicsObject maila1;
private PhysicsObject maila2;
public override void Begin()
{
LuoKentta();
PhysicsObject pallo = LuoKentta();
AsetaOhjaimet();
AloitaPeli();
AloitaPeli(pallo);
}
private void LuoKentta()
private PhysicsObject LuoKentta()
{
Level.Background.Color = Color.Black;
pallo = new PhysicsObject(40.0, 40.0);
PhysicsObject pallo = new PhysicsObject(40.0, 40.0);
pallo.Shape = Shape.Circle;
pallo.X = -200.0;
pallo.Y = 0.0;
......@@ -34,9 +30,6 @@ public class Pong : PhysicsGame
pallo.MomentOfInertia = Double.PositiveInfinity;
Add(pallo);
maila1 = LuoMaila(this, Level.Left + 20.0, 0.0);
maila2 = LuoMaila(this, Level.Right - 20.0, 0.0);
PhysicsObject vasenReuna = Level.CreateLeftBorder();
vasenReuna.Restitution = 1.0;
vasenReuna.KineticFriction = 0.0;
......@@ -64,6 +57,8 @@ public class Pong : PhysicsGame
alaReuna.KineticFriction = 0.0;
Camera.ZoomToLevel();
return pallo;
}
......@@ -98,7 +93,7 @@ public class Pong : PhysicsGame
}
private void AloitaPeli()
private void AloitaPeli(PhysicsObject pallo)
{
Vector impulssi = new Vector(500.0, 0.0);
pallo.Hit(impulssi * pallo.Mass);
......@@ -107,6 +102,9 @@ public class Pong : PhysicsGame
private void AsetaOhjaimet()
{
PhysicsObject maila1 = LuoMaila(this, Level.Left + 20.0, 0.0);
PhysicsObject maila2 = LuoMaila(this, Level.Right - 20.0, 0.0);
Keyboard.Listen(Key.A, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa ylös", this, maila1, nopeusYlos);
Keyboard.Listen(Key.A, ButtonState.Released, AsetaNopeus, null, this, maila1, Vector.Zero);
Keyboard.Listen(Key.Z, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa alas", this, maila1, nopeusAlas);
......
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