Yet Another Game Engine
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
yage
physics
body.h
Go to the documentation of this file.
1
10
#pragma once
11
12
#include <
math/matrix.h
>
13
14
namespace
yage
15
{
16
17
class
Body
18
{
19
public
:
20
// gravity constant
21
static
const
double
GRAVITY
;
22
23
protected
:
24
// center of mass of the object
25
Vector2d
position_
=
Vector2d
(0, 0);
26
27
// mass of the object
28
double
mass_
= 1;
29
30
// current velocity of the object
31
Vector2d
velocity_
=
Vector2d
(0, 0);
32
33
// boolean that defines if gravity can act on the object
34
bool
gravity_
=
true
;
35
36
// current acceleration
37
Vector2d
acceleration_
=
Vector2d
(0, 0);
38
39
// force acting on the body
40
Vector2d
force_
=
Vector2d
(0, 0);
41
42
public
:
43
// apply force to the object and update the velocity
44
virtual
void
applyForce
(
const
Vector2d
&force) = 0;
45
virtual
void
update
() = 0;
46
47
double
xPosition
()
const
;
48
double
yPosition
()
const
;
49
50
protected
:
51
// protected constructor to initialize member variables
52
Body
(
Vector2d
position =
Vector2d
(0, 0),
double
mass = 1,
53
Vector2d
velocity =
Vector2d
(0, 0),
bool
gravity =
false
);
54
};
55
56
}
// namespace yage
yage::Body::gravity_
bool gravity_
Definition:
body.h:34
yage::Body::xPosition
double xPosition() const
Definition:
body.cpp:19
yage::Body::GRAVITY
static const double GRAVITY
Definition:
body.h:21
yage::Body::applyForce
virtual void applyForce(const Vector2d &force)=0
yage::Body::force_
Vector2d force_
Definition:
body.h:40
yage::Vector2< double >
yage::Body::yPosition
double yPosition() const
Definition:
body.cpp:24
yage::Body
Definition:
body.h:17
yage::Body::Body
Body(Vector2d position=Vector2d(0, 0), double mass=1, Vector2d velocity=Vector2d(0, 0), bool gravity=false)
Definition:
body.cpp:29
yage::Body::velocity_
Vector2d velocity_
Definition:
body.h:31
matrix.h
-*- c++ -*-
yage::Vector2d
Vector2< double > Vector2d
Definition of a 2D vector.
Definition:
matrix.h:394
yage::Body::acceleration_
Vector2d acceleration_
Definition:
body.h:37
yage::Body::mass_
double mass_
Definition:
body.h:28
yage::Body::update
virtual void update()=0
yage::Body::position_
Vector2d position_
Definition:
body.h:25
Generated on Sat Jun 23 2018 15:09:53 by
1.8.6