From 37cd937cbd232323ab51764dd8a29da442f9fb55 Mon Sep 17 00:00:00 2001 From: Emilia Date: Mon, 25 Mar 2024 21:25:50 +0000 Subject: [PATCH] Move InertiaComponent to Ex3 --- Expansion1/ExampleInputComponent.cs | 2 +- Expansion2/ExampleShootingInputComponent.cs | 1 + .../InertiaComponent.cs | 31 +++++++++++-------- Program.cs | 1 + 4 files changed, 21 insertions(+), 14 deletions(-) rename {Expansion2 => Expansion3}/InertiaComponent.cs (76%) diff --git a/Expansion1/ExampleInputComponent.cs b/Expansion1/ExampleInputComponent.cs index 23ccac2..0532d7b 100644 --- a/Expansion1/ExampleInputComponent.cs +++ b/Expansion1/ExampleInputComponent.cs @@ -1,7 +1,7 @@ using Smoll; using Raylib_cs; using System.Numerics; -using Smoll.Ex2; +using Smoll.Ex3; namespace Smoll.Ex1 { diff --git a/Expansion2/ExampleShootingInputComponent.cs b/Expansion2/ExampleShootingInputComponent.cs index bf26712..d177b94 100644 --- a/Expansion2/ExampleShootingInputComponent.cs +++ b/Expansion2/ExampleShootingInputComponent.cs @@ -2,6 +2,7 @@ using Smoll; using Raylib_cs; using System.Numerics; using Smoll.Ex1; +using Smoll.Ex3; namespace Smoll.Ex2 { diff --git a/Expansion2/InertiaComponent.cs b/Expansion3/InertiaComponent.cs similarity index 76% rename from Expansion2/InertiaComponent.cs rename to Expansion3/InertiaComponent.cs index 976855d..45ef465 100644 --- a/Expansion2/InertiaComponent.cs +++ b/Expansion3/InertiaComponent.cs @@ -1,34 +1,39 @@ using System.Numerics; -namespace Smoll.Ex2 { - sealed class InertiaComponent : Component { +namespace Smoll.Ex3 +{ + sealed class InertiaComponent : Component + { public Transform2D transform; public float dampening; private Transform2DComponent? ownerTransform; - public InertiaComponent(float dampening = 1) - : this(dampening,0,0,0) - {} + public InertiaComponent(float dampening = 1) + : this(dampening, 0, 0, 0) + { } - public InertiaComponent(float dampening, float x, float y) - : this(dampening,x,y,0) - {} + public InertiaComponent(float dampening, float x, float y) + : this(dampening, x, y, 0) + { } - public InertiaComponent(float dampening, float x, float y, float angle) { + public InertiaComponent(float dampening, float x, float y, float angle) + { transform = new Transform2D(); - transform.position = y*Complex.ImaginaryOne + x; + transform.position = y * Complex.ImaginaryOne + x; transform.angle = angle; transform.scale = 1; this.dampening = dampening; } - public InertiaComponent(float dampening, Transform2D tr) { + public InertiaComponent(float dampening, Transform2D tr) + { transform = tr; this.dampening = dampening; } - public override void OnAttached() { + public override void OnAttached() + { ownerTransform = owner.GetComponent(); } @@ -41,7 +46,7 @@ namespace Smoll.Ex2 { transform.position *= MathF.Pow(dampening, deltaTimeSeconds); transform.angle *= MathF.Pow(dampening, deltaTimeSeconds); - + } } diff --git a/Program.cs b/Program.cs index 8d25816..b12499a 100644 --- a/Program.cs +++ b/Program.cs @@ -2,6 +2,7 @@ using Smoll; using Smoll.Ex1; using Smoll.Ex2; +using Smoll.Ex3; Raylib.InitWindow(800, 600, "Smoll");