2020-02-19 12:50:09 -05:00
|
|
|
#ifndef GAME_H
|
|
|
|
#define GAME_H
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include <SFML/System/Time.hpp>
|
|
|
|
#include <SFML/Window.hpp>
|
|
|
|
|
2020-02-20 13:34:41 -05:00
|
|
|
#include "hero.h"
|
|
|
|
#include "level.h"
|
|
|
|
|
|
|
|
/// The main class where all the process happens
|
2020-02-19 12:50:09 -05:00
|
|
|
class Game
|
|
|
|
{
|
|
|
|
private:
|
2020-02-20 13:34:41 -05:00
|
|
|
// Game entities
|
|
|
|
std::unique_ptr<Hero> hero;
|
|
|
|
std::unique_ptr<Level> level;
|
|
|
|
|
|
|
|
// SFML entities
|
2020-02-19 12:50:09 -05:00
|
|
|
std::unique_ptr<sf::Clock> clock;
|
|
|
|
sf::Window main_window;
|
|
|
|
|
2020-02-20 13:34:41 -05:00
|
|
|
/// Convert pressed key into a game direction
|
|
|
|
Direction getDirection(sf::Keyboard::Key &key) const;
|
|
|
|
|
|
|
|
/// Move player by pressed key
|
|
|
|
void onMoving(sf::Keyboard::Key &key);
|
|
|
|
|
2020-02-19 12:50:09 -05:00
|
|
|
public:
|
|
|
|
explicit Game();
|
|
|
|
|
2020-02-20 13:34:41 -05:00
|
|
|
/// Start the game loop
|
2020-02-19 12:50:09 -05:00
|
|
|
int run();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // GAME_H
|