Sokoban
Public Member Functions | Private Member Functions | List of all members
SokobanApp Class Reference

Class representing game window. More...

#include <SokobanApp.h>

Inheritance diagram for SokobanApp:

Public Member Functions

void setup () override
 
void draw () override
 
void keyDown (ci::app::KeyEvent event) override
 
 SokobanApp ()
 

Private Member Functions

 ~SokobanApp ()
 
This is the group of the functions for buttons.
void button_load ()
 
void button_restart ()
 
void button_solve ()
 
void button_play_solution ()
 
void button_login ()
 
void button_previous_map ()
 
void button_next_map ()
 
Tool functions. For settings app parameters, drawing map, etc.
void set_new_map_params ()
 
void set_no_map_params ()
 
void set_high_score_strings ()
 
void draw_map ()
 
void initialize_users_progress ()
 
void initialize_highscore ()
 
void initialize_textures ()
 
void create_menu ()
 

Private Attributes

Variables defining current game status such as current loaded map, current user, sizes, etc.
bool keys_disabled
 
bool new_map_set
 
bool complete
 
bool solved
 
int s_x
 
int s_y
 
std::string map_pack_id
 
int current_map_index
 
std::string m_user
 
Usercurrent_user
 
Strings which are drawed in app including highscores, status line, map name.
std::string status_line_word
 
std::string map_best_word
 
std::string user_best_word
 
std::string map_pack_name_word
 
std::string user_name_word
 
std::string game_mode_word
 
Variables representing an engine of the game including list of maps, highscore database, timer, list of users
std::vector< std::unique_ptr< Map > > list_of_maps
 
ci::params::InterfaceGlRef mParams
 
ci::gl::Texture2dRef textures [SinglePlayerMap::NUMBER_OF_FIELDS]
 
MyTimer timer
 
std::vector< Useravailable_users
 
HighScore highScore
 

Static Private Attributes

Constans used in application.
static const float FONT_SIZE
 
static const float FIELD_SIZE_X
 
static const float FIELD_SIZE_Y
 
static const float MENU_X
 
static const float MENU_Y
 
static const float MENU_OFFSET
 
static const float TEXT_BOX_HEIGHT
 
static const float STATUS_WORD_DEFAULT_LENGTH
 
static const char MAP_SEPARATOR
 
static const char USERS_SETINGS_SEPARATOR
 
static const char MAP_ID_SEPARATOR
 
static const int MAX_MAP_PACK_ID_LENGTH
 
static const char USER_SOURCE_FILE []
 
static const char HIGHSCORE_SOURCE_FILE []
 
static const char MAP_HIHGSCORE_LABEL []
 
static const char USER_HIGHSCORE_LABEL []
 
static const char MAP_PACK_LOADED_LABEL []
 
static const char NUMBER_OF_MAP_LOADED_LABEL []
 
static const std::vector< char > FORBIDDEN_MAP_ID_CHARS
 
static const std::vector< char > FORBIDDEN_USER_NAME_CHARS
 
static const std::vector< std::string > extensions
 

Detailed Description

Class representing game window.

It is responsible to creating game environment and to interaction with keys.

Constructor & Destructor Documentation

◆ SokobanApp()

SokobanApp::SokobanApp ( )

◆ ~SokobanApp()

SokobanApp::~SokobanApp ( )
private

Destructor. Writes highscore and the data of users to files.

Member Function Documentation

◆ button_load()

void SokobanApp::button_load ( )
private

Function for loading map pack (button load in menu).

◆ button_login()

void SokobanApp::button_login ( )
private

Funcion for the logging in the user (button login).

◆ button_next_map()

void SokobanApp::button_next_map ( )
private

Function for the loading the next map from the map pack (button next map).

◆ button_play_solution()

void SokobanApp::button_play_solution ( )
private

Funcion for the button which do next step in the solution of map.

◆ button_previous_map()

void SokobanApp::button_previous_map ( )
private

Function for the loading the previous map from the map pack (button previous map).

◆ button_restart()

void SokobanApp::button_restart ( )
private

Function for restarting current map (button restart in menu).

◆ button_solve()

void SokobanApp::button_solve ( )
private

Function for the button solve (solving current map)

◆ create_menu()

void SokobanApp::create_menu ( )
private

Creates menu (adds buttons, etc.).

◆ draw()

void SokobanApp::draw ( )
override

◆ draw_map()

void SokobanApp::draw_map ( )
private

Drawa the current loaded map (game grid).

◆ initialize_highscore()

void SokobanApp::initialize_highscore ( )
private

Loads highscore database from the data file.

◆ initialize_textures()

void SokobanApp::initialize_textures ( )
private

Loads images representing game emelemts (ground, wall, etc.) as textures.

◆ initialize_users_progress()

void SokobanApp::initialize_users_progress ( )
private

Loads users progress from the data file.

◆ keyDown()

void SokobanApp::keyDown ( ci::app::KeyEvent  event)
override

◆ set_high_score_strings()

void SokobanApp::set_high_score_strings ( )
private

Set highscore for the current loaded map.

◆ set_new_map_params()

void SokobanApp::set_new_map_params ( )
private

Sets parametrs (strings, size, etc.) for the current loaded map.

◆ set_no_map_params()

void SokobanApp::set_no_map_params ( )
private

Sets parametrs (strings, size, etc.) for the situation when no map is loaded.

◆ setup()

void SokobanApp::setup ( )
override

Member Data Documentation

◆ available_users

std::vector<User> SokobanApp::available_users
private

Vector of users which have ever played the game.

◆ complete

bool SokobanApp::complete
private

Bool variable which determines if the map (puzzle) is solved by user.

◆ current_map_index

int SokobanApp::current_map_index
private

Integer variable representing which map from the list of maps is played.

◆ current_user

User* SokobanApp::current_user
private

Pointer to user which is logged in.

◆ extensions

const std::vector<std::string> SokobanApp::extensions
staticprivate

Vector of prefered extensions for map pack files.

◆ FIELD_SIZE_X

const float SokobanApp::FIELD_SIZE_X
staticprivate

Width (in pixels) of the cell in game grid which represents a game element (ground, wall, barrel etc.)

◆ FIELD_SIZE_Y

const float SokobanApp::FIELD_SIZE_Y
staticprivate

Height (in pixels) of the cell in game grid which represents a game element (ground, wall, barrel etc.)

◆ FONT_SIZE

const float SokobanApp::FONT_SIZE
staticprivate

Size of font for drawing game information.

◆ FORBIDDEN_MAP_ID_CHARS

const std::vector<char> SokobanApp::FORBIDDEN_MAP_ID_CHARS
staticprivate

Vectors of the forbidden symbols in map id.

◆ FORBIDDEN_USER_NAME_CHARS

const std::vector<char> SokobanApp::FORBIDDEN_USER_NAME_CHARS
staticprivate

Vectors of the forbidden symbols in user name.

◆ game_mode_word

std::string SokobanApp::game_mode_word
private

String which contains "single player" or "multi player" according to the game mode.

◆ highScore

HighScore SokobanApp::highScore
private

Highscore database.

◆ HIGHSCORE_SOURCE_FILE

const char SokobanApp::HIGHSCORE_SOURCE_FILE[]
staticprivate

Name of the source file for highscore data.

◆ keys_disabled

bool SokobanApp::keys_disabled
private

Bool variable which determines if keys are disabled.

◆ list_of_maps

std::vector<std::unique_ptr<Map> > SokobanApp::list_of_maps
private

◆ m_user

std::string SokobanApp::m_user
private

String representing a content of text box for user logging in

◆ map_best_word

std::string SokobanApp::map_best_word
private

String which contains best highscore for the current map.

◆ MAP_HIHGSCORE_LABEL

const char SokobanApp::MAP_HIHGSCORE_LABEL[]
staticprivate

Label which is drawed before map highscore.

◆ MAP_ID_SEPARATOR

const char SokobanApp::MAP_ID_SEPARATOR
staticprivate

Character which separates name of map pack and the number of map which is played. This two strings are made map id for highscore.

◆ map_pack_id

std::string SokobanApp::map_pack_id
private

◆ MAP_PACK_LOADED_LABEL

const char SokobanApp::MAP_PACK_LOADED_LABEL[]
staticprivate

Label which is drawed before the current map pack name.

◆ map_pack_name_word

std::string SokobanApp::map_pack_name_word
private

String which contains name of the current loaded map pack.

◆ MAP_SEPARATOR

const char SokobanApp::MAP_SEPARATOR
staticprivate

Character which must be at the end of map file.

◆ MAX_MAP_PACK_ID_LENGTH

const int SokobanApp::MAX_MAP_PACK_ID_LENGTH
staticprivate

Maximal length of the map pack id.

◆ MENU_OFFSET

const float SokobanApp::MENU_OFFSET
staticprivate

Distance between the menu and the game grid and between the menu and the border of window.

◆ MENU_X

const float SokobanApp::MENU_X
staticprivate

Width (in pixels) of the menu.

◆ MENU_Y

const float SokobanApp::MENU_Y
staticprivate

Height (in pixels) of the menu.

◆ mParams

ci::params::InterfaceGlRef SokobanApp::mParams
private

Feature of Cinder library which represents a menu in this app.

◆ new_map_set

bool SokobanApp::new_map_set
private

Bool variable which determines if the new map was loaded.

◆ NUMBER_OF_MAP_LOADED_LABEL

const char SokobanApp::NUMBER_OF_MAP_LOADED_LABEL[]
staticprivate

Label which is drawed before the current map index within map pack.

◆ s_x

int SokobanApp::s_x
private

Width of current map which is drawed (number of cells)

◆ s_y

int SokobanApp::s_y
private

Width of current map which is drawed (number of cells)

◆ solved

bool SokobanApp::solved
private

Bool variable which determines if solver have solved the map.

◆ status_line_word

std::string SokobanApp::status_line_word
private

String which contains the word describing the current game status.

◆ STATUS_WORD_DEFAULT_LENGTH

const float SokobanApp::STATUS_WORD_DEFAULT_LENGTH
staticprivate

Default length of the word which describes a game status.

◆ TEXT_BOX_HEIGHT

const float SokobanApp::TEXT_BOX_HEIGHT
staticprivate

Height of all words which are drawed.

◆ textures

ci::gl::Texture2dRef SokobanApp::textures[SinglePlayerMap::NUMBER_OF_FIELDS]
private

Array of textures which represents game elemets.

◆ timer

MyTimer SokobanApp::timer
private

Timer which measures the length of finding solution

◆ user_best_word

std::string SokobanApp::user_best_word
private

String which contains the best highscore for the current user.

◆ USER_HIGHSCORE_LABEL

const char SokobanApp::USER_HIGHSCORE_LABEL[]
staticprivate

Label which is drawed before user highscore.

◆ user_name_word

std::string SokobanApp::user_name_word
private

not used

◆ USER_SOURCE_FILE

const char SokobanApp::USER_SOURCE_FILE[]
staticprivate

Name of the source file for user data (proress).

◆ USERS_SETINGS_SEPARATOR

const char SokobanApp::USERS_SETINGS_SEPARATOR
staticprivate

Character which separates information for users in data file.


The documentation for this class was generated from the following file: