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 |
|
|
11 |
|
197
|
12 |
#include "Terrain.hh"
|
|
13 |
class PhysicsWorld;
|
|
14 |
|
|
15 |
#include "PhysicsObject.hh"
|
|
16 |
#include "Vector.hh"
|
|
17 |
#include "Config.hh"
|
|
18 |
#include "Projectile.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 |
CL_Timer tick_timer;
|
|
29 |
uint32_t tick_counter;
|
|
30 |
|
|
31 |
// Terrain terrain;
|
|
32 |
|
|
33 |
protected:
|
|
34 |
std::list<PhysicsObject*> players;
|
|
35 |
std::list<Shot*> projectiles;
|
|
36 |
// std::vector<PhysicsObject*> objects;
|
|
37 |
|
|
38 |
// Contains connections between signals and slots
|
|
39 |
CL_SlotContainer slots;
|
|
40 |
|
|
41 |
// TODO: Should these be somewhere else?
|
|
42 |
Vector dimensions;
|
|
43 |
Vector gravity;
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
public:
|
199
|
48 |
|
|
49 |
PhysicsWorld(Vector gravity, Vector dimensions);
|
|
50 |
|
197
|
51 |
// TODO: Replace addObject with these?
|
|
52 |
//void addPlayerObject(PlayerObject *object);
|
|
53 |
//void addProjectileObject(ProjectileObject *object);
|
|
54 |
|
|
55 |
/**
|
|
56 |
* Add object to the PhysicsWorld.
|
|
57 |
*
|
|
58 |
* @param object Pointer to the PhysicsObject to add.
|
|
59 |
*/
|
|
60 |
void addPlayerObject(PhysicsObject *object);
|
|
61 |
|
|
62 |
void addProjectile(Shot *projectile);
|
|
63 |
|
|
64 |
/**
|
|
65 |
* Advance one time step in physics simulation.
|
|
66 |
*/
|
|
67 |
void tick();
|
|
68 |
|
|
69 |
/**
|
|
70 |
* Get current tick in physics simulation.
|
|
71 |
*
|
|
72 |
* @return tick Current simulation tick.
|
|
73 |
*/
|
|
74 |
uint32_t getTick();
|
|
75 |
|
|
76 |
virtual void draw(CL_GraphicContext *gc);
|
|
77 |
|
|
78 |
// TODO This should probably be protected or in GameStat or in GameStatee
|
|
79 |
};
|
|
80 |
|
|
81 |
#endif
|