summaryrefslogtreecommitdiffhomepage
path: root/src/physics.hpp
diff options
context:
space:
mode:
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);
}