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