42
|
1 |
#ifndef PHYSICS_HH
|
|
2 |
#define PHYSICS_HH
|
|
3 |
|
|
4 |
#include "Vector.hh"
|
|
5 |
|
|
6 |
const uint16_t PHYSICS_TICK_MS = 50;
|
|
7 |
const uint16_t PHYSICS_WORLD_WIDTH = 800;
|
|
8 |
const uint16_t PHYSICS_WORLD_HEIGHT = 600;
|
|
9 |
|
|
10 |
class PhysicsWorld {
|
|
11 |
protected:
|
|
12 |
std::vector<PhysicsObject*> objects;
|
|
13 |
Vector dimensions;
|
|
14 |
|
|
15 |
PhysicsWorld (Vector dimensions);
|
|
16 |
|
|
17 |
public:
|
|
18 |
void addObject (PhysicsObject *object);
|
|
19 |
|
|
20 |
void tick (void);
|
|
21 |
};
|
|
22 |
|
|
23 |
class PhysicsObject {
|
|
24 |
protected:
|
|
25 |
Vector position;
|
|
26 |
Vector velocity;
|
|
27 |
Vector force;
|
|
28 |
uint16_t mass;
|
|
29 |
|
|
30 |
PhysicsObject (mass, position, velocity, force);
|
|
31 |
|
|
32 |
private:
|
|
33 |
void updatePosition (void);
|
|
34 |
|
|
35 |
protected:
|
|
36 |
void applyForce (Vector force);
|
|
37 |
void updatePhysics (Vector position, Vector velocity, Vector force);
|
|
38 |
|
|
39 |
public:
|
|
40 |
Vector getPosition (void);
|
|
41 |
|
|
42 |
void tick (void);
|
|
43 |
};
|
|
44 |
|
|
45 |
#endif
|