From f710101fce665ee77bd6506b5602e2b2e3a4d73b Mon Sep 17 00:00:00 2001
From: Vesa Lappalainen <vesal@jyu.fi>
Date: Sun, 1 Oct 2023 20:18:37 +0300
Subject: [PATCH] =?UTF-8?q?pong=20muutetaan=20k=C3=A4ytt=C3=A4m=C3=A4?=
 =?UTF-8?q?=C3=A4n=20C#=20ominaisuuksia,=20ei=20v=C3=A4ltt=C3=A4m=C3=A4tt?=
 =?UTF-8?q?=C3=A4=20hy=C3=B6ty=C3=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 luennot/luento09/Pong/Pong.cs | 44 ++++++++++++++++++++---------------
 1 file changed, 25 insertions(+), 19 deletions(-)

diff --git a/luennot/luento09/Pong/Pong.cs b/luennot/luento09/Pong/Pong.cs
index 7ef1d6c..a576be1 100644
--- a/luennot/luento09/Pong/Pong.cs
+++ b/luennot/luento09/Pong/Pong.cs
@@ -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);
     }
 
-- 
GitLab