This repository has been archived by the owner on Jun 7, 2018. It is now read-only.
/
Game.h
executable file
·147 lines (120 loc) · 5.02 KB
/
Game.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
* Copyright (C) 2006-2012 Christopho, Solarus - http://www.solarus-games.org
*
* Solarus is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Solarus is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SOLARUS_GAME_H
#define SOLARUS_GAME_H
#include "Common.h"
#include "Transition.h"
#include "GameControls.h"
#include "Savegame.h"
/**
* @brief Represents the game currently running.
*
* The game shows the current map and displays all game elements:
* the map entities, the HUD, the pause menu, the dialog box, etc.
*/
class Game {
private:
// main objects
MainLoop& main_loop; /**< the main loop object */
Savegame* savegame; /**< the game data saved */
Hero *hero;
// current game state (elements currently shown)
bool pause_key_available; /**< indicates that the player is allowed to use the pause key */
PauseMenu *pause_menu; /**< the current pause menu, or NULL if the game is not paused */
GameoverSequence *gameover_sequence; /**< the game over sequence (if currently shown) */
bool resetting; /**< true if the program will be reset */
bool restarting; /**< true if the game will be restarted */
// controls
GameControls *controls; /**< this object receives the keyboard and joypad events */
KeysEffect *keys_effect; /**< current effect associated to the main game keys
* (represented on the HUD by the action icon, the objects icons, etc.) */
// map
Map *current_map; /**< the map currently displayed */
Map *next_map; /**< the map where the hero is going to; if not NULL, it means that the hero
* is changing from current_map to next_map */
Surface *previous_map_surface; /**< a copy of the previous map surface for transition effects that display two maps */
Transition::Style transition_style; /**< the transition style between the current map and the next one */
Transition *transition; /**< the transition currently shown, or NULL if no transition is playing */
// world (i.e. the current set of maps)
Dungeon *dungeon; /**< the dungeon of the current map, of NULL if we are not in a dungeon */
bool crystal_state; /**< indicates that a crystal has been enabled (i.e. the orange blocks are raised) */
static Rectangle outside_world_size; /**< size of the outside world in pixels */
// graphics
HUD *hud; /**< the game HUD (displaying hearts, rupees, key icons, etc.) */
bool hud_enabled; /**< true if the HUD is currently displayed */
DialogBox *dialog_box; /**< the dialog box manager */
// update functions
void update_keys_effect();
void update_dialog_box();
void update_transitions();
void update_gameover_sequence();
void load_dungeon();
public:
// creation and destruction
Game(MainLoop& main_loop, Savegame* savegame);
~Game();
void start();
void stop();
// global objects
MainLoop& get_main_loop();
LuaContext& get_lua_context();
Hero& get_hero();
const Rectangle& get_hero_xy();
GameControls& get_controls();
KeysEffect& get_keys_effect();
Savegame& get_savegame();
Equipment& get_equipment();
// functions called by the main loop
bool notify_input(InputEvent &event);
void update();
void draw(Surface& dst_surface);
// game controls
void key_pressed(GameControls::GameKey key);
void key_released(GameControls::GameKey key);
// map
bool has_current_map();
Map& get_current_map();
void set_current_map(const std::string& map_id, const std::string &destination_name,
Transition::Style transition_style);
// world
const Rectangle& get_outside_world_size();
bool is_in_dungeon();
Dungeon& get_current_dungeon();
bool get_crystal_state();
void change_crystal_state();
// current game state
bool is_paused();
bool is_showing_dialog();
bool is_playing_transition();
bool is_showing_gameover();
bool is_suspended(); // true if at least one of the three functions above returns true
// HUD
void set_hud_enabled(bool hud_enabled);
// pause
bool can_pause();
bool is_pause_key_available();
void set_pause_key_available(bool pause_key_available);
void set_paused(bool paused);
// dialog box
DialogBox& get_dialog_box();
// game over
void start_gameover_sequence();
void get_back_from_death();
void reset();
void restart();
};
#endif