author | terom |
Tue, 18 Nov 2008 22:50:29 +0000 | |
changeset 66 | 1415a2d45686 |
parent 64 | 81302d3350eb |
child 69 | 309c11126949 |
permissions | -rw-r--r-- |
42 | 1 |
#ifndef PHYSICS_HH |
2 |
#define PHYSICS_HH |
|
3 |
||
4 |
#include "Vector.hh" |
|
5 |
||
50
9e1a6506f5a1
some rough-handed code modifications towards a newer, better, working Physics
terom
parents:
48
diff
changeset
|
6 |
#include <ClanLib/core.h> |
9e1a6506f5a1
some rough-handed code modifications towards a newer, better, working Physics
terom
parents:
48
diff
changeset
|
7 |
|
64 | 8 |
const uint16_t PHYSICS_TICK_MS = 10; |
42 | 9 |
|
50
9e1a6506f5a1
some rough-handed code modifications towards a newer, better, working Physics
terom
parents:
48
diff
changeset
|
10 |
// forward-declare |
9e1a6506f5a1
some rough-handed code modifications towards a newer, better, working Physics
terom
parents:
48
diff
changeset
|
11 |
class PhysicsObject; |
9e1a6506f5a1
some rough-handed code modifications towards a newer, better, working Physics
terom
parents:
48
diff
changeset
|
12 |
|
42 | 13 |
class PhysicsWorld { |
60 | 14 |
friend class PhysicsObject; |
15 |
||
50
9e1a6506f5a1
some rough-handed code modifications towards a newer, better, working Physics
terom
parents:
48
diff
changeset
|
16 |
private: |
9e1a6506f5a1
some rough-handed code modifications towards a newer, better, working Physics
terom
parents:
48
diff
changeset
|
17 |
CL_Timer tick_timer; |
9e1a6506f5a1
some rough-handed code modifications towards a newer, better, working Physics
terom
parents:
48
diff
changeset
|
18 |
|
42 | 19 |
protected: |
20 |
std::vector<PhysicsObject*> objects; |
|
60 | 21 |
Vector gravity; |
42 | 22 |
Vector dimensions; |
50
9e1a6506f5a1
some rough-handed code modifications towards a newer, better, working Physics
terom
parents:
48
diff
changeset
|
23 |
|
9e1a6506f5a1
some rough-handed code modifications towards a newer, better, working Physics
terom
parents:
48
diff
changeset
|
24 |
CL_SlotContainer slots; |
42 | 25 |
|
60 | 26 |
PhysicsWorld (Vector gravity, Vector dimensions); |
42 | 27 |
|
28 |
public: |
|
29 |
void addObject (PhysicsObject *object); |
|
30 |
||
31 |
void tick (void); |
|
32 |
}; |
|
33 |
||
34 |
class PhysicsObject { |
|
35 |
protected: |
|
60 | 36 |
PhysicsWorld &world; |
37 |
float mass; |
|
42 | 38 |
Vector position; |
39 |
Vector velocity; |
|
40 |
||
60 | 41 |
PhysicsObject (PhysicsWorld &world, float mass, Vector position, Vector velocity); |
42 | 42 |
|
43 |
private: |
|
44 |
void updatePosition (void); |
|
45 |
||
46 |
protected: |
|
66 | 47 |
virtual void applyForce (Vector force, uint16_t dt); |
60 | 48 |
void updatePhysics (Vector position, Vector velocity); |
42 | 49 |
|
50 |
public: |
|
51 |
Vector getPosition (void); |
|
52 |
||
53 |
void tick (void); |
|
54 |
}; |
|
55 |
||
56 |
#endif |