From f34116f1da8465851d684620b6b94e0a3f3c0fbc Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Tue, 22 Jun 2021 20:23:33 -0400 Subject: Impulses, and entirely finished with rigid body demo #1 --- 2d/rigidbody/rigidbody_1/snippet2.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to '2d/rigidbody/rigidbody_1/snippet2.cpp') diff --git a/2d/rigidbody/rigidbody_1/snippet2.cpp b/2d/rigidbody/rigidbody_1/snippet2.cpp index 8ad468c..1288209 100644 --- a/2d/rigidbody/rigidbody_1/snippet2.cpp +++ b/2d/rigidbody/rigidbody_1/snippet2.cpp @@ -6,14 +6,6 @@ struct Rigidbody { Vector2 position = { 0, 0 }; float32 mass = 1.f; - void applyForce(Vector2 f) { - force += f; - } - - void applyGravity(float32 deltaTimeSeconds) { - velocity += (Vector2 { 0.f, -50.f } * deltaTimeSeconds); - } - void update(float32 deltaTimeSeconds) { applyGravity(deltaTimeSeconds); @@ -22,4 +14,12 @@ struct Rigidbody { position += (velocity * deltaTimeSeconds); force = Vector2 { 0.f, 0.f }; } + + void applyGravity(float32 deltaTimeSeconds) { + velocity += (Vector2 { 0.f, -9.8.f } * deltaTimeSeconds); + } + + void applyForce(Vector2 f) { + force += f; + } }; -- cgit v1.2.1