YAGE
0.02
Yet Another Game Engine
include
YAGE
Physics
body.hpp
1
/* ----------------------------------------------------------------------------
2
* body.hpp
3
*
4
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License
5
* See file LICENSE for more details
6
* ----------------------------------------------------------------------------
7
*/
8
9
#ifndef YAGE_PHYSICS_BODY_HPP
10
#define YAGE_PHYSICS_BODY_HPP
11
12
#include "
Math/matrix.hpp
"
13
14
namespace
yage
{
15
class
Body {
16
public
:
17
// gravity constant
18
static
const
double
GRAVITY;
19
20
protected
:
21
// center of mass of the object
22
Vector2d
position_ =
Vector2d
(0, 0);
23
24
// mass of the object
25
double
mass_ = 1;
26
27
// current velocity of the object
28
Vector2d
velocity_ =
Vector2d
(0, 0);
29
30
// boolean that defines if gravity can act on the object
31
bool
gravity_ =
true
;
32
33
// current acceleration
34
Vector2d
acceleration_ =
Vector2d
(0, 0);
35
36
// force acting on the body
37
Vector2d
force_ =
Vector2d
(0, 0);
38
39
public
:
40
// apply force to the object and update the velocity
41
virtual
void
applyForce(
const
Vector2d& force) = 0;
42
virtual
void
update() = 0;
43
44
double
xPosition()
const
;
45
double
yPosition()
const
;
46
47
protected
:
48
// protected constructor to initialize member variables
49
Body(
const
Vector2d& position =
Vector2d
(0, 0),
double
mass = 1,
const
Vector2d& velocity =
Vector2d
(0, 0),
bool
gravity =
false
);
50
};
51
}
// namespace yage
52
53
#endif
matrix.hpp
Templated matrix class.
yage::Vector2d
Vector2< double > Vector2d
Definition of a 2D vector.
Definition:
matrix.hpp:313
yage
Definition:
camera2d.hpp:17
Generated on Sun Aug 13 2017 17:40:54 for YAGE by
1.8.13