author | Tero Marttila <terom@fixme.fi> |
Sat, 17 Jan 2009 02:58:36 +0200 | |
changeset 405 | 7a8c7a0a1261 |
parent 300 | 417183866f35 |
child 408 | e6cfc44266af |
permissions | -rw-r--r-- |
197 | 1 |
#ifndef PHYSICS_WORLD_HH |
2 |
#define PHYSICS_WORLD_HH |
|
3 |
||
4 |
#include <ClanLib/display.h> |
|
5 |
#include <ClanLib/core.h> |
|
6 |
||
7 |
#include <algorithm> |
|
8 |
#include <functional> |
|
9 |
#include <cmath> |
|
199 | 10 |
|
205 | 11 |
#include "Terrain.hh" |
199 | 12 |
|
197 | 13 |
class PhysicsWorld; |
14 |
||
15 |
#include "PhysicsObject.hh" |
|
16 |
#include "Vector.hh" |
|
205 | 17 |
#include "Timer.hh" |
197 | 18 |
#include "Config.hh" |
19 |
||
20 |
/** |
|
21 |
* PhysicsWorld class. PhysicsWorld contains PhysicsObjects that are |
|
22 |
* simulated in the PhysicsWorld. |
|
23 |
*/ |
|
24 |
class PhysicsWorld : public Terrain { |
|
25 |
friend class PhysicsObject; |
|
26 |
||
27 |
private: |
|
28 |
||
208 | 29 |
|
197 | 30 |
protected: |
222
293ddf4c067d
reorganize PhysicsObject/Player/Projectile lists so that PhysicsObject doesn't need to know about its subclasses anymore, and PhysicsWorld doesn't need to know about GameState
ekku
parents:
208
diff
changeset
|
31 |
std::list<PhysicsObject*> objects; |
197 | 32 |
|
33 |
// Contains connections between signals and slots |
|
34 |
CL_SlotContainer slots; |
|
35 |
||
36 |
Vector dimensions; |
|
37 |
Vector gravity; |
|
38 |
||
39 |
public: |
|
208 | 40 |
// Someone is going to kill me for this |
41 |
Timer tick_timer; |
|
42 |
||
199 | 43 |
PhysicsWorld(Vector gravity, Vector dimensions); |
44 |
||
225 | 45 |
/** |
197 | 46 |
* Add object to the PhysicsWorld. |
47 |
* |
|
48 |
* @param object Pointer to the PhysicsObject to add. |
|
49 |
*/ |
|
222
293ddf4c067d
reorganize PhysicsObject/Player/Projectile lists so that PhysicsObject doesn't need to know about its subclasses anymore, and PhysicsWorld doesn't need to know about GameState
ekku
parents:
208
diff
changeset
|
50 |
void addPhysicsObject(PhysicsObject *object); |
197 | 51 |
|
52 |
/** |
|
225 | 53 |
* Remove the object from the PhysicsWorld. |
54 |
*/ |
|
55 |
void removePhysicsObject (PhysicsObject *po); |
|
56 |
||
57 |
/** |
|
197 | 58 |
* Advance one time step in physics simulation. |
59 |
*/ |
|
300 | 60 |
void tick (TimeMS tick_length); |
197 | 61 |
|
62 |
/** |
|
63 |
* Get current tick in physics simulation. |
|
64 |
* |
|
65 |
* @return tick Current simulation tick. |
|
66 |
*/ |
|
300 | 67 |
TickCount getTicks (void); |
197 | 68 |
}; |
69 |
||
70 |
#endif |