sliding-puzzle/application.h

43 lines
874 B
C++

#pragma once
#include <SFML/Window/Keyboard.hpp>
#include "board.h"
class Application
{
public:
enum class STATE
{
PLAY,
WIN
} current_state;
explicit Application(unsigned int window_width, unsigned int window_height);
// Init game
bool init(const std::string& path, int splitting);
// Launch game
void run();
// Refresh render_window to actual state
void draw();
// Handle keyboard commands
void processInput();
// Handle events for player to move cursor and swap tiles
void onGameState(sf::Event& event);
// Handle events for winning state after the image gets assembled
void onWinState(sf::Event& event);
private:
// Convert keyboard keys into moving direction
DIRECTION getDirection(sf::Keyboard::Key &key) const;
Board board;
sf::RenderWindow render_window;
};