HeadBall  1.0
A game
Game.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <SFML/Graphics.hpp>
4 #include <box2d/box2d.h>
5 #include <string>
6 #include <memory>
7 
8 #include "StateMachine.hpp"
9 #include "InputManager.hpp"
10 #include "AssetManager.hpp"
11 #include "TimeManager.hpp"
12 
13 namespace HeadBall {
18  struct GameData {
19  sf::RenderWindow window;
23  };
24 
29  struct ScoreTimeData {
31  int p1Score;
32  int p2Score;
33  };
34 
39  typedef std::shared_ptr <GameData> GameDataRef;
40 
45  typedef std::shared_ptr <ScoreTimeData> ScoreTimeRef;
46 
51  typedef std::shared_ptr <b2World> WorldRef;
52 
57  class Game {
58  public:
66  Game (int width, int height, std::string title);
67 
68  private:
73  void run ( );
74 
75  const float dt = 1.0f / 60.0f;
76  sf::Clock _clock;
77 
78  GameDataRef _data = std::make_shared <GameData> ( );
79  };
80 }
Class for managing assets.
Definition: AssetManager.hpp:13
Class where game loop is processed.
Definition: Game.hpp:57
Game(int width, int height, std::string title)
Construct a new Game object.
Definition: Game.cpp:5
const float dt
The delta time for framerate management.
Definition: Game.hpp:75
GameDataRef _data
The shared pointer of game data.
Definition: Game.hpp:78
void run()
Run the game loop.
Definition: Game.cpp:12
sf::Clock _clock
The clock for getting ti.
Definition: Game.hpp:76
Handle the input given by the user.
Definition: InputManager.hpp:14
The class that manages the states in the project.
Definition: StateMachine.hpp:23
The class that manages the game time.
Definition: TimeManager.hpp:11
Custom namespace used throughout the project.
Definition: AboutState.cpp:6
std::shared_ptr< b2World > WorldRef
The Shared Pointer that points to the Box2D world.
Definition: Game.hpp:51
std::shared_ptr< ScoreTimeData > ScoreTimeRef
The Shared Pointer of ScoreTimeData struct.
Definition: Game.hpp:45
std::shared_ptr< GameData > GameDataRef
The Shared Pointer of GameData Struct.
Definition: Game.hpp:39
Struct where the necessaey game data used by all the states is stored.
Definition: Game.hpp:18
AssetManager assets
Definition: Game.hpp:22
StateMachine machine
Definition: Game.hpp:20
InputManager input
Definition: Game.hpp:21
sf::RenderWindow window
Definition: Game.hpp:19
Struct where the game time and player score is stored.
Definition: Game.hpp:29
TimeManager time
Definition: Game.hpp:30
int p2Score
Definition: Game.hpp:32
int p1Score
Definition: Game.hpp:31