summaryrefslogtreecommitdiffhomepage
path: root/src/physics.hpp
diff options
context:
space:
mode:
authorarngo <[email protected]>2022-11-09 19:25:39 -0500
committerarngo <[email protected]>2022-11-09 19:25:39 -0500
commit1a828584a93918e5e2ed5e7d218d00dc50922ae0 (patch)
tree39211689618f5812c52d507a63f1867d514d29ee /src/physics.hpp
parenta9649b97ddfb0b39f8b3c27b14a7d855b1e824fa (diff)
downloadorbital_game-1a828584a93918e5e2ed5e7d218d00dc50922ae0.tar.gz
orbital_game-1a828584a93918e5e2ed5e7d218d00dc50922ae0.zip
add classes for kinematic and dynamic body
each class has a static unordered_set that stores references to each object created
Diffstat (limited to 'src/physics.hpp')
-rw-r--r--src/physics.hpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/physics.hpp b/src/physics.hpp
index e26df15..de6172a 100644
--- a/src/physics.hpp
+++ b/src/physics.hpp
@@ -1,8 +1,8 @@
#pragma once
+#include <unordered_set>
#include "raylib.h"
namespace Physics {
-
class Body {
public:
Vector2 position;
@@ -11,10 +11,28 @@ namespace Physics {
Body(Vector2 position, Vector2 velocity, float mass);
};
+ // TODO: replace these hardcoded bodies with dynamic/kinematic bodies in gameplay system
extern Body ship;// = Body((Vector2){50,50}, (Vector2){0,1}, 1);
extern Body rock;// = Body((Vector2){400,400}, (Vector2){0,0}, 50);
+ class DynamicBody : public Body {
+ private:
+ static std::unordered_set<DynamicBody*> dynamicBodies;
+ public:
+ void apply_force(Vector2 force);
+ DynamicBody(Vector2 position, Vector2 velocity, float mass);
+ ~DynamicBody();
+ };
+
+ class KinematicBody : public Body {
+ private:
+ static std::unordered_set<KinematicBody*> kinematicBodies;
+ public:
+ KinematicBody(Vector2 position, Vector2 velocity, float mass);
+ ~KinematicBody();
+ };
+
//0.01667
- void step(float deltaTime);
+ void step(float deltaTime, int times=1);
Vector2 get_grav_force(Body body1, Body body2);
}