You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
885 B
C++

#ifndef GAME_H
#define GAME_H
#include <memory>
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/System/Time.hpp>
#include <SFML/Window.hpp>
#include "hero.h"
#include "level.h"
constexpr int cell_length = 20;
constexpr int window_side = cell_length * side;
/// The main class where all the process happens
class Game
{
private:
// Game entities
std::unique_ptr<Hero> hero;
std::unique_ptr<Level> level;
// SFML entities
std::unique_ptr<sf::Clock> clock;
sf::RenderWindow main_window;
/// Convert pressed key into a game direction
Direction getDirection(sf::Keyboard::Key &key) const;
/// Move player by pressed key
Direction onMoving(sf::Keyboard::Key &key);
/// Render game state
void renderMap(const Direction direction);
public:
explicit Game();
/// Start the game loop
int run();
};
#endif // GAME_H