src/proto2/Physics.hh
branchno-netsession
changeset 35 e21cfda0edde
child 41 ca80cd67785d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/proto2/Physics.hh	Tue Nov 18 22:58:50 2008 +0000
@@ -0,0 +1,55 @@
+#ifndef PHYSICS_HH
+#define PHYSICS_HH
+
+#include "Vector.hh"
+
+#include <ClanLib/core.h>
+
+const uint16_t PHYSICS_TICK_MS = 10;
+
+// forward-declare
+class PhysicsObject;
+
+class PhysicsWorld {
+    friend class PhysicsObject;
+            
+    private:
+        CL_Timer tick_timer;
+
+    protected:
+        std::vector<PhysicsObject*> objects;
+        Vector gravity;
+        Vector dimensions;
+
+        CL_SlotContainer slots;
+        
+        PhysicsWorld (Vector gravity, Vector dimensions);
+
+    public:
+        void addObject (PhysicsObject *object);
+
+        void tick (void);
+};
+
+class PhysicsObject {
+    protected:
+        PhysicsWorld &world;
+        float mass;
+        Vector position;
+        Vector velocity;
+    
+        PhysicsObject (PhysicsWorld &world, float mass, Vector position, Vector velocity);
+
+        virtual void applyForce (Vector force, uint16_t dt);
+        void updatePhysics (Vector position, Vector velocity);
+    
+    private:
+        void updatePosition (void);
+
+    public:
+        Vector getPosition (void);
+
+        void tick (void);
+};
+
+#endif