diff options
| author | arngo <[email protected]> | 2022-11-05 21:57:15 -0400 |
|---|---|---|
| committer | arngo <[email protected]> | 2022-11-05 21:57:15 -0400 |
| commit | a9649b97ddfb0b39f8b3c27b14a7d855b1e824fa (patch) | |
| tree | 272b950a831cdd54bcfc1d0221463bfb8d1ddac8 /src/physics.cpp | |
| parent | ceb76492b07dbeda6949f35008999d0f400e49fd (diff) | |
| download | orbital_game-a9649b97ddfb0b39f8b3c27b14a7d855b1e824fa.tar.gz orbital_game-a9649b97ddfb0b39f8b3c27b14a7d855b1e824fa.zip | |
add times parameter to step function
Diffstat (limited to 'src/physics.cpp')
| -rw-r--r-- | src/physics.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/physics.cpp b/src/physics.cpp index df45085..b8d4e29 100644 --- a/src/physics.cpp +++ b/src/physics.cpp @@ -17,11 +17,13 @@ namespace Physics { Body rock = Body((Vector2){400,400}, (Vector2){0,0}, 50); //0.01667 - void step(float deltaTime) { - // calculate position change - Vector2 grav_force = get_grav_force(ship, rock); - ship.velocity = Vector2Add(ship.velocity, Vector2Scale(grav_force, deltaTime)); - ship.position = Vector2Add(ship.position, Vector2Scale(ship.velocity, deltaTime)); + void step(float deltaTime, int times) { + for (int i = 0; i < times; i++) { + // calculate position change + Vector2 grav_force = get_grav_force(ship, rock); + ship.velocity = Vector2Add(ship.velocity, Vector2Scale(grav_force, deltaTime)); + ship.position = Vector2Add(ship.position, Vector2Scale(ship.velocity, deltaTime)); + } } Vector2 get_grav_force(Body body1, Body body2) { |
