Platformer
Platformer
PhysicsManager.hpp
1 #ifndef PHYSICS_MANAGER_HPP
2 #define PHYSICS_MANAGER_HPP
3 
4 #include <Box2D/Box2D.h>
5 #include <memory>
6 
11  public:
13  static PhysicsManager& instance();
14 
16  void init();
17 
19  void shutdown();
20 
25  static std::shared_ptr<b2World> GetWorld();
26 
28  static void SetGravity(
29  float x,
31  float y);
32 
34  void Step();
35 
37  PhysicsManager(const PhysicsManager&) = delete;
38 
40  PhysicsManager& operator=(const PhysicsManager&) = delete;
41 
42  private:
45 
48 
50  std::shared_ptr<b2World> world;
51 };
52 
53 #endif
PhysicsManager()
Constructs a PhysicsManager.
Definition: PhysicsManager.cpp:5
void shutdown()
Shuts down the physics manager.
Definition: PhysicsManager.cpp:18
static PhysicsManager & instance()
The singleton instance of the PhysicsManager.
Definition: PhysicsManager.cpp:9
void init()
Initializes the physics manager.
Definition: PhysicsManager.cpp:14
std::shared_ptr< b2World > world
The Box2D world of this physics manager.
Definition: PhysicsManager.hpp:50
This class manages the physics of our game as a singleton.
Definition: PhysicsManager.hpp:10
static std::shared_ptr< b2World > GetWorld()
Gets the Box2D world of the physics manager.
Definition: PhysicsManager.cpp:20
PhysicsManager & operator=(const PhysicsManager &)=delete
Stop the compiler from generating methods to copy the object.
~PhysicsManager()
Destructs a PhysicsManager.
Definition: PhysicsManager.cpp:6
void Step()
Initiates a step of the physics simulation for all physics objects in the world.
Definition: PhysicsManager.cpp:26
static void SetGravity(float x, float y)
Sets the gravity of this physics manager.
Definition: PhysicsManager.cpp:22