author | ekku |
Mon, 01 Dec 2008 23:43:05 +0000 | |
changeset 170 | fe74105c07ea |
parent 169 | 71c5b12a2b3f |
child 180 | bfe1077edab3 |
permissions | -rw-r--r-- |
42 | 1 |
#ifndef PHYSICS_HH |
2 |
#define PHYSICS_HH |
|
3 |
||
72 | 4 |
#include <vector> |
83
cbba9729e92b
Integrointia fyssaan, jotain pikkubugausta havaittavissa.
saiam
parents:
79
diff
changeset
|
5 |
#include <queue> |
50
9e1a6506f5a1
some rough-handed code modifications towards a newer, better, working Physics
terom
parents:
48
diff
changeset
|
6 |
#include <ClanLib/core.h> |
138
cc326b64ae20
Nyt kaivaminen visualisoidaan oikein, mutta fysiikkakoodi on kyll? edelleen ihan kauheata, pit?isi tuo Terrain v??nt??
saiam
parents:
136
diff
changeset
|
7 |
#include <ClanLib/display.h> |
50
9e1a6506f5a1
some rough-handed code modifications towards a newer, better, working Physics
terom
parents:
48
diff
changeset
|
8 |
|
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
9 |
#include "Vector.hh" |
136
3a15a5937f7a
Moved constants to one header Config.hh, we probably should use somekind of resourcemanager. But do we have time for that? :)
saiam
parents:
135
diff
changeset
|
10 |
#include "Config.hh" |
150
5e032b540af3
Now it uses Terrain class, but it isn't properly integrated to the infrastructure.
saiam
parents:
138
diff
changeset
|
11 |
#include "Terrain.hh" |
78 | 12 |
|
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
13 |
// Forward declares |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
14 |
class PhysicsWorld; |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
15 |
class PhysicsObject; |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
16 |
class PlayerObject; |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
17 |
class ProjectileObject; |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
18 |
class Shape; |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
19 |
struct Derivative; |
42 | 20 |
|
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
21 |
// Type definitions |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
22 |
typedef uint16_t TimeMS; |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
23 |
typedef Vector Force; |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
24 |
|
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
25 |
/** |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
26 |
* PhysicsWorld class. PhysicsWorld contains PhysicsObjects that are |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
27 |
* simulated in the PhysicsWorld. |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
28 |
*/ |
161
ea2f295c279f
Made PhysicsWorld to inherit Terrain instead of having it as an attribute.
saiam
parents:
153
diff
changeset
|
29 |
class PhysicsWorld : public Terrain { |
60 | 30 |
friend class PhysicsObject; |
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
31 |
|
70 | 32 |
private: |
33 |
CL_Timer tick_timer; |
|
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
34 |
uint32_t tick_counter; |
105 | 35 |
|
161
ea2f295c279f
Made PhysicsWorld to inherit Terrain instead of having it as an attribute.
saiam
parents:
153
diff
changeset
|
36 |
// Terrain terrain; |
150
5e032b540af3
Now it uses Terrain class, but it isn't properly integrated to the infrastructure.
saiam
parents:
138
diff
changeset
|
37 |
|
70 | 38 |
protected: |
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
39 |
//std::vector<PlayerObject*> players; |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
40 |
//std::vector<ProjectileObject*> projectiles; |
70 | 41 |
std::vector<PhysicsObject*> objects; |
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
42 |
|
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
43 |
// Contains connections between signals and slots |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
44 |
CL_SlotContainer slots; |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
45 |
|
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
46 |
PhysicsWorld(Vector gravity, Vector dimensions); |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
47 |
|
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
48 |
// TODO: Should these be somewhere else? |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
49 |
Vector dimensions; |
70 | 50 |
Vector gravity; |
86 | 51 |
|
150
5e032b540af3
Now it uses Terrain class, but it isn't properly integrated to the infrastructure.
saiam
parents:
138
diff
changeset
|
52 |
|
71 | 53 |
|
86 | 54 |
public: |
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
55 |
// TODO: Replace addObject with these? |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
56 |
//void addPlayerObject(PlayerObject *object); |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
57 |
//void addProjectileObject(ProjectileObject *object); |
70 | 58 |
|
123 | 59 |
/** |
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
60 |
* Add object to the PhysicsWorld. |
123 | 61 |
* |
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
62 |
* @param object Pointer to the PhysicsObject to add. |
123 | 63 |
*/ |
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
64 |
void addObject(PhysicsObject *object); |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
65 |
|
123 | 66 |
/** |
67 |
* Advance one time step in physics simulation. |
|
68 |
*/ |
|
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
69 |
void tick(); |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
70 |
|
123 | 71 |
/** |
72 |
* Get current tick in physics simulation. |
|
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
73 |
* |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
74 |
* @return tick Current simulation tick. |
123 | 75 |
*/ |
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
76 |
uint32_t getTick(); |
105 | 77 |
|
42 | 78 |
}; |
79 |
||
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
80 |
/** |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
81 |
* PhysicObject class. A basic PhysicsObject class. |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
82 |
*/ |
42 | 83 |
class PhysicsObject { |
70 | 84 |
protected: |
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
85 |
// This probably shouldn't be done this way. |
70 | 86 |
PhysicsWorld &world; |
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
87 |
|
70 | 88 |
Vector position; |
89 |
Vector velocity; |
|
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
90 |
float mass; |
128
890ac82cdcc0
Documenting more, cleaning variables. This code needs some serious
saiam
parents:
123
diff
changeset
|
91 |
bool inAir; // Is the object "on the ground" |
83
cbba9729e92b
Integrointia fyssaan, jotain pikkubugausta havaittavissa.
saiam
parents:
79
diff
changeset
|
92 |
|
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
93 |
// Attributes for players |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
94 |
float aim; // Aim direction (half circle) |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
95 |
bool facingRight; // Player facing |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
96 |
|
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
97 |
PhysicsObject(PhysicsWorld &world, float mass, Vector position, |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
98 |
Vector velocity); |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
99 |
~PhysicsObject() {} |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
100 |
|
108 | 101 |
|
96
4a801210096c
fix movement physics+network code to some degree, jumping is now buggy?
terom
parents:
95
diff
changeset
|
102 |
/** |
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
103 |
* Add force to the force queue to be applied on next tick. |
108 | 104 |
* |
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
105 |
* @param force Force vector |
108 | 106 |
*/ |
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
107 |
void applyForce(Force force); |
96
4a801210096c
fix movement physics+network code to some degree, jumping is now buggy?
terom
parents:
95
diff
changeset
|
108 |
|
4a801210096c
fix movement physics+network code to some degree, jumping is now buggy?
terom
parents:
95
diff
changeset
|
109 |
/** |
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
110 |
* Change player aim |
129 | 111 |
* |
112 |
* @param da Aim angle change |
|
108 | 113 |
*/ |
114 |
void changeAim(float da); |
|
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
115 |
|
108 | 116 |
/** |
117 |
* Set player facing. |
|
129 | 118 |
* |
119 |
* @param facingRight True if player is facing right. |
|
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
120 |
*/ |
129 | 121 |
void setFacing(bool facingRight); |
108 | 122 |
|
123 |
/** |
|
170 | 124 |
* Makes the player jump in the air. |
125 |
* @param direction -1: jump left, 0: jump up, 1: jump right |
|
96
4a801210096c
fix movement physics+network code to some degree, jumping is now buggy?
terom
parents:
95
diff
changeset
|
126 |
*/ |
170 | 127 |
void jump(int direction); |
98 | 128 |
|
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
129 |
/** |
98 | 130 |
* Handle ground-bounce |
129 | 131 |
* |
132 |
* @param normal Normal vector relative to which to bounce |
|
98 | 133 |
*/ |
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
134 |
void bounce(Vector normal); |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
135 |
|
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
136 |
/** |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
137 |
* Called on network clients to sync state from server |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
138 |
* |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
139 |
* @param position New position |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
140 |
* @param velocity New velocity |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
141 |
* @param inAir New inAir value |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
142 |
*/ |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
143 |
void updatePhysics(Vector position, Vector velocity, bool inAir); |
96
4a801210096c
fix movement physics+network code to some degree, jumping is now buggy?
terom
parents:
95
diff
changeset
|
144 |
|
70 | 145 |
private: |
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
146 |
// TODO: I'd be tempted to use some already made ClanLib structure |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
147 |
// here. |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
148 |
// Shape of the object. Edge points of the shape polygon. |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
149 |
std::vector<Vector> shape; |
129 | 150 |
|
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
151 |
// TODO: Should these operations be moved to PhysicsWorld? |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
152 |
// Force queue that is emptied on every tick |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
153 |
std::queue<Force> forceq; |
69 | 154 |
|
70 | 155 |
/** |
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
156 |
* Handle player movement and apply forces. |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
157 |
*/ |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
158 |
void updatePosition(); |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
159 |
|
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
160 |
// TODO: Should these be moved to PhysicsWorld? |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
161 |
/** |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
162 |
* Use RK4 to integrate the effects of force over a time interwall. |
129 | 163 |
* |
164 |
* @param force Force to integrate |
|
165 |
* @param dt Time intervall |
|
70 | 166 |
*/ |
169
71c5b12a2b3f
Removed unnecessary PhysicsObject attribute posAfterTick and velAfterTick and made integrate to use references.
saiam
parents:
161
diff
changeset
|
167 |
void integrate(Force force, TimeMS dt, Vector &posAfterTick, Vector &velAfterTick); |
129 | 168 |
|
169 |
/** |
|
170 |
* Evaluate the value of the derivative at given time |
|
171 |
* |
|
172 |
* @param force Force |
|
173 |
* @param dt Time |
|
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
174 |
* @param d Previous derivative |
129 | 175 |
*/ |
169
71c5b12a2b3f
Removed unnecessary PhysicsObject attribute posAfterTick and velAfterTick and made integrate to use references.
saiam
parents:
161
diff
changeset
|
176 |
Derivative evaluate(Force force, TimeMS dt, Derivative &d, const Vector &posAfterTick, const Vector &velAfterTick); |
129 | 177 |
|
178 |
/** |
|
179 |
* Return object acceleration with given force. |
|
180 |
* |
|
181 |
* @param force Force |
|
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
182 |
* @return Acceleration |
129 | 183 |
*/ |
85 | 184 |
Vector acceleration(const Force &force); |
83
cbba9729e92b
Integrointia fyssaan, jotain pikkubugausta havaittavissa.
saiam
parents:
79
diff
changeset
|
185 |
|
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
186 |
// TODO: If integration is moved to PhysicsWorld then this should |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
187 |
// also move there. |
134 | 188 |
/** |
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
189 |
* Handle ground movement. |
134 | 190 |
* |
191 |
* @param right Boolean describing the movement direction. |
|
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
192 |
* @return New position |
134 | 193 |
*/ |
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
194 |
Vector walk(bool right); |
134 | 195 |
|
129 | 196 |
/* |
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
197 |
* Handle collision. TODO: This is not used. It probably should |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
198 |
* be? |
129 | 199 |
*/ |
116 | 200 |
virtual void onCollision() {} |
201 |
||
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
202 |
/* |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
203 |
* TODO: This probably does some kind of collision |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
204 |
* detection. Could be named/documented better. |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
205 |
*/ |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
206 |
bool possibleLocation(Vector loc); |
132
957c3c184ea0
Changed some variables that were protected to private from PhysicsObject
saiam
parents:
131
diff
changeset
|
207 |
|
70 | 208 |
public: |
129 | 209 |
/** |
210 |
* Get current object position. |
|
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
211 |
* |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
212 |
* @return Position vector |
129 | 213 |
*/ |
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
214 |
Vector getPosition(); |
129 | 215 |
|
216 |
/** |
|
217 |
* Return object shape. |
|
218 |
* |
|
219 |
* @return Polygon points |
|
220 |
*/ |
|
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
221 |
std::vector<Vector>& getShape(); |
129 | 222 |
|
223 |
/** |
|
224 |
* Set object shape. |
|
225 |
* |
|
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
226 |
* @param shape Vector containing polygon poinst |
129 | 227 |
*/ |
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
228 |
void setShape(std::vector<Vector> shape); |
108 | 229 |
|
129 | 230 |
/** |
231 |
* Return object facing. |
|
232 |
* |
|
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
233 |
* @return Object facing (true if facing right) |
129 | 234 |
*/ |
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
235 |
bool getFacing(); |
129 | 236 |
|
237 |
/** |
|
238 |
* Return object aim angle. |
|
239 |
* |
|
240 |
* @return Object aim angle |
|
241 |
*/ |
|
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
242 |
float getAim(); |
108 | 243 |
|
129 | 244 |
/** |
245 |
* Update object in physics simulation. |
|
246 |
*/ |
|
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
247 |
void tick(); |
153
73402d5b778e
Lots of small fixe. Moved drawing PhysicsObjects away from Graphics.cc.
saiam
parents:
150
diff
changeset
|
248 |
|
73402d5b778e
Lots of small fixe. Moved drawing PhysicsObjects away from Graphics.cc.
saiam
parents:
150
diff
changeset
|
249 |
/** |
73402d5b778e
Lots of small fixe. Moved drawing PhysicsObjects away from Graphics.cc.
saiam
parents:
150
diff
changeset
|
250 |
* Draw object |
73402d5b778e
Lots of small fixe. Moved drawing PhysicsObjects away from Graphics.cc.
saiam
parents:
150
diff
changeset
|
251 |
* |
73402d5b778e
Lots of small fixe. Moved drawing PhysicsObjects away from Graphics.cc.
saiam
parents:
150
diff
changeset
|
252 |
* @param gc CL_GraphicContext |
73402d5b778e
Lots of small fixe. Moved drawing PhysicsObjects away from Graphics.cc.
saiam
parents:
150
diff
changeset
|
253 |
*/ |
73402d5b778e
Lots of small fixe. Moved drawing PhysicsObjects away from Graphics.cc.
saiam
parents:
150
diff
changeset
|
254 |
void draw(CL_GraphicContext *gc); |
42 | 255 |
}; |
256 |
||
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
257 |
// TODO: This could probably be moved somewhere else or removed |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
258 |
// completely. |
83
cbba9729e92b
Integrointia fyssaan, jotain pikkubugausta havaittavissa.
saiam
parents:
79
diff
changeset
|
259 |
struct Derivative { |
cbba9729e92b
Integrointia fyssaan, jotain pikkubugausta havaittavissa.
saiam
parents:
79
diff
changeset
|
260 |
Vector dx; // Velocity |
cbba9729e92b
Integrointia fyssaan, jotain pikkubugausta havaittavissa.
saiam
parents:
79
diff
changeset
|
261 |
Vector dv; // Acceleration |
cbba9729e92b
Integrointia fyssaan, jotain pikkubugausta havaittavissa.
saiam
parents:
79
diff
changeset
|
262 |
}; |
cbba9729e92b
Integrointia fyssaan, jotain pikkubugausta havaittavissa.
saiam
parents:
79
diff
changeset
|
263 |
|
cbba9729e92b
Integrointia fyssaan, jotain pikkubugausta havaittavissa.
saiam
parents:
79
diff
changeset
|
264 |
|
135
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
265 |
// TODO: These are drafts |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
266 |
/** |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
267 |
* PlayerObject class. Represents a player in the physics engine. |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
268 |
*/ |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
269 |
//class PlayerObject : public PhysicsObject { |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
270 |
|
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
271 |
//}; |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
272 |
|
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
273 |
/** |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
274 |
* ProjectileObject class. Represents different projectiles in the |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
275 |
* physics (i.e. not players) in the physics engine. |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
276 |
*/ |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
277 |
//class ProjectileObject : public PhysicsObject { |
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
278 |
|
d5624d698a78
Physics.hh rewrite. Documenting and suggesting changes.
saiam
parents:
134
diff
changeset
|
279 |
//}; |
83
cbba9729e92b
Integrointia fyssaan, jotain pikkubugausta havaittavissa.
saiam
parents:
79
diff
changeset
|
280 |
|
42 | 281 |
#endif |