YAGE
v0.1.1
Yet Another Game Engine
body.h
Go to the documentation of this file.
1
/* ----------------------------------------------------------------------------
2
* body.h
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_H
10
#define YAGE_PHYSICS_BODY_H
11
12
#include <
YAGE/Math/matrix.h
>
13
14
namespace
yage
15
{
16
class
Body
17
{
18
public
:
19
// gravity constant
20
static
const
double
GRAVITY
;
21
22
protected
:
23
// center of mass of the object
24
Vector2d
position_
=
Vector2d
(0, 0);
25
26
// mass of the object
27
double
mass_
= 1;
28
29
// current velocity of the object
30
Vector2d
velocity_
=
Vector2d
(0, 0);
31
32
// boolean that defines if gravity can act on the object
33
bool
gravity_
=
true
;
34
35
// current acceleration
36
Vector2d
acceleration_
=
Vector2d
(0, 0);
37
38
// force acting on the body
39
Vector2d
force_
=
Vector2d
(0, 0);
40
41
public
:
42
// apply force to the object and update the velocity
43
virtual
void
applyForce
(
const
Vector2d
&force) = 0;
44
virtual
void
update
() = 0;
45
46
double
xPosition
()
const
;
47
double
yPosition
()
const
;
48
49
protected
:
50
// protected constructor to initialize member variables
51
Body
(
Vector2d
position =
Vector2d
(0, 0),
double
mass = 1,
52
Vector2d
velocity =
Vector2d
(0, 0),
bool
gravity =
false
);
53
};
54
}
// namespace yage
55
56
#endif
yage::Body::gravity_
bool gravity_
Definition:
body.h:33
yage::Body::GRAVITY
static const double GRAVITY
Definition:
body.h:20
yage::Body::applyForce
virtual void applyForce(const Vector2d &force)=0
yage::Body::force_
Vector2d force_
Definition:
body.h:39
yage::Vector2< double >
yage::Body::xPosition
double xPosition() const
Definition:
body.cpp:18
yage::Body
Definition:
body.h:16
yage::Body::Body
Body(Vector2d position=Vector2d(0, 0), double mass=1, Vector2d velocity=Vector2d(0, 0), bool gravity=false)
Definition:
body.cpp:28
yage::Body::velocity_
Vector2d velocity_
Definition:
body.h:30
yage::Body::yPosition
double yPosition() const
Definition:
body.cpp:23
matrix.h
yage::Vector2d
Vector2< double > Vector2d
Definition of a 2D vector.
Definition:
matrix.h:352
yage::Body::acceleration_
Vector2d acceleration_
Definition:
body.h:36
yage::Body::mass_
double mass_
Definition:
body.h:27
yage::Body::update
virtual void update()=0
yage
Project namespace.
Definition:
body.cpp:13
yage::Body::position_
Vector2d position_
Definition:
body.h:24
include
YAGE
Physics
body.h
Generated on Sat Sep 2 2017 12:28:04 for YAGE by
1.8.13