LPCGame
A Simple 2d Game Engine
Main Page
Related Pages
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Enumerations
Enumerator
Pages
physics.h
1
#ifndef PHYSICS_H
2
#define PHYSICS_H
3
4
#include <cmath>
5
#include <vector>
6
#include "external/json/json.h"
7
#include "base.h"
8
#include "math.h"
9
#include "motionstate.h"
10
15
const
int
GROUND_FRICTION = 800;
16
18
23
class
Physics
{
24
public
:
25
Physics
();
26
~
Physics
();
31
void
Move
(
float
deltaT);
33
Vector2f
Position
()
const
;
34
Vector2f
Velocity()
const
;
35
Vector2f
Acceleration()
const
;
36
Rectf
Box()
const
;
37
int
State
()
const
;
39
void
SetPosition
(
Vector2f
pos);
40
void
SetVelocity(
Vector2f
vel);
41
void
SetAcceleration(
Vector2f
accel);
43
void
SetHorizDir
(
int
moveDir);
45
void
SetVertDir
(
int
moveDir);
50
void
SetDirection
(
Vector2f
v);
51
void
SetPhysConstants(
PhysicalConstants
physConstants);
52
void
SetBox(
Rectf
box);
53
void
SetMap(CollisionMap map);
58
Json::Value
Save
()
const
;
63
void
Load
(
Json::Value
val);
64
65
private
:
70
void
UpdateVelocity(
float
deltaT);
74
void
ApplyAcceleration();
79
void
ApplyFriction();
85
bool
CheckCollision(
Rectf
box);
86
87
public
:
89
enum
MOVE
{ STOP = -1 };
90
91
private
:
92
Kinematic
mKinematic;
93
MotionState
mMotionState;
94
PhysicalConstants
mPhysConstants;
95
Rectf
mBox;
96
CollisionMap mCollisionMap;
97
int
mHorizDir, mVertDir;
98
Vector2f
mDir;
99
};
100
101
#endif
Users
Will
Documents
Programs
LPCGame
src
core
physics.h
Generated on Tue Jan 29 2013 18:58:09 for LPCGame by
1.8.2