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

pong muutetaan käyttämään C# ominaisuuksia, ei välttämättä hyötyä

parent f2cd4990
No related branches found
No related tags found
No related merge requests found
...@@ -5,8 +5,8 @@ namespace Pong; ...@@ -5,8 +5,8 @@ namespace Pong;
public class Pong : PhysicsGame public class Pong : PhysicsGame
{ {
private readonly Vector nopeusYlos = new Vector(0, 200); private readonly Vector nopeusYlos = new (0, 200);
private readonly Vector nopeusAlas = new Vector(0, -200); private readonly Vector nopeusAlas = new (0, -200);
public override void Begin() public override void Begin()
...@@ -21,13 +21,15 @@ public class Pong : PhysicsGame ...@@ -21,13 +21,15 @@ public class Pong : PhysicsGame
{ {
Level.BackgroundColor = Color.Black; Level.BackgroundColor = Color.Black;
PhysicsObject pallo = new PhysicsObject(40.0, 40.0); PhysicsObject pallo = new (40.0, 40.0)
pallo.Shape = Shape.Circle; {
pallo.X = -200.0; Shape = Shape.Circle,
pallo.Y = 0.0; X = -200.0,
pallo.Restitution = 1.0; Y = 0.0,
pallo.KineticFriction = 0.0; Restitution = 1.0,
pallo.MomentOfInertia = Double.PositiveInfinity; KineticFriction = 0.0,
MomentOfInertia = Double.PositiveInfinity
};
Add(pallo); Add(pallo);
PhysicsObject vasenReuna = Level.CreateLeftBorder(); PhysicsObject vasenReuna = Level.CreateLeftBorder();
...@@ -77,16 +79,20 @@ public class Pong : PhysicsGame ...@@ -77,16 +79,20 @@ public class Pong : PhysicsGame
public static IntMeter LuoPisteLaskuri(PhysicsGame peli, double x, double y) public static IntMeter LuoPisteLaskuri(PhysicsGame peli, double x, double y)
{ {
IntMeter laskuri = new IntMeter(0); IntMeter laskuri = new(0)
laskuri.MaxValue = 10; {
MaxValue = 10
Label naytto = new Label(); };
Label naytto = new()
{
X = x,
Y = y,
TextColor = Color.White,
BorderColor = peli.Level.BackgroundColor,
Color = peli.Level.BackgroundColor,
};
naytto.BindTo(laskuri); naytto.BindTo(laskuri);
naytto.X = x;
naytto.Y = y;
naytto.TextColor = Color.White;
naytto.BorderColor = peli.Level.BackgroundColor;
naytto.Color = peli.Level.BackgroundColor;
peli.Add(naytto); peli.Add(naytto);
return laskuri; return laskuri;
...@@ -95,7 +101,7 @@ public class Pong : PhysicsGame ...@@ -95,7 +101,7 @@ public class Pong : PhysicsGame
private void AloitaPeli(PhysicsObject pallo) private void AloitaPeli(PhysicsObject pallo)
{ {
Vector impulssi = new Vector(500.0, 0.0); Vector impulssi = new(500.0, 0.0);
pallo.Hit(impulssi * pallo.Mass); pallo.Hit(impulssi * pallo.Mass);
} }
......
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