Gamedev Framework (gf)  0.10.0
A C++14 framework for 2D games
PhysicsModel.h
1 #ifndef GF_PHYSICS_MODEL_H
2 #define GF_PHYSICS_MODEL_H
3 
4 #include <vector>
5 
6 #include "Model.h"
7 #include "Vector.h"
8 
9 namespace gf {
10 #ifndef DOXYGEN_SHOULD_SKIP_THIS
11 inline namespace v1 {
12 #endif
13 
14  class PhysicsBody;
15 
22  class GF_API PhysicsModel : public gf::Model {
23  public:
29  PhysicsModel(Vector2f gravity = { 0.0f, 0.0f });
30 
36  void setGravity(Vector2f gravity) noexcept {
37  m_gravity = gravity;
38  }
39 
45  Vector2f getGravity() const noexcept {
46  return m_gravity;
47  }
48 
54  void addBody(PhysicsBody& body);
55 
61  void removeBody(PhysicsBody& body);
62 
66  void clear();
67 
68  virtual void update(Time time) override;
69 
70  private:
71  Vector2f m_gravity;
72  std::vector<PhysicsBody*> m_staticBodies;
73  std::vector<PhysicsBody*> m_dynamicBodies;
74  };
75 
76 #ifndef DOXYGEN_SHOULD_SKIP_THIS
77 }
78 #endif
79 }
80 
81 #endif // GF_PHYSICS_MODEL_H
A physics body.
Definition: PhysicsBody.h:36
Represents a time value.
Definition: Time.h:74
A game object that can be updated.
Definition: Model.h:46
void setGravity(Vector2f gravity) noexcept
Set the gravity of the simulation.
Definition: PhysicsModel.h:36
The namespace for gf classes.
Definition: Action.h:34
A model for physics simulation.
Definition: PhysicsModel.h:22
Vector2f getGravity() const noexcept
Get the gravity of the simulation.
Definition: PhysicsModel.h:45