blob: 170ef49178fad6dc6c99f0aad15c80ad9c74ece8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#ifndef YAGE_BODDY_HPP
#define YAGE_BODDY_HPP
#include <glm/glm.hpp>
namespace yage
{
class Body
{
protected:
// current force acting on object
glm::vec2 force_;
// current velocity of the object
glm::vec2 velocity_;
// center of mass of the object
glm::vec2 center_of_mass_;
// mass of the object
double mass_;
// boolean that defines if gravity can act on the object
bool gravity_;
public:
virtual ~Body() {}
// apply force to the object and update the velocity
virtual void applyForce(const glm::vec2 &force)=0;
protected:
// protected constructor to initialize member variables
Body(const glm::vec2 ¢er_of_mass, double mass, const glm::vec2 &force, const glm::vec2 &velocity, bool gravity) :
force_(force), velocity_(velocity), center_of_mass_(center_of_mass),
mass_(mass), gravity_(gravity)
{}
};
} // yage
#endif
|