Mana
Loading...
Searching...
No Matches
game.h
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2004-2009 The Mana World Development Team
4 * Copyright (C) 2009-2012 The Mana Developers
5 *
6 * This file is part of The Mana Client.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24#include <string>
25
26#include "gui/windowmenu.h"
27
28#include "utils/time.h"
29
30class Map;
31
36class Game
37{
38 public:
43 Game();
44
48 ~Game();
49
53 static Game *instance() { return mInstance; }
54
59 void logic();
60
61 bool keyDownEvent(SDL_KeyboardEvent &event);
62
63 void handleInput();
64
65 void changeMap(const std::string &mapName);
66
71
72 const std::string &getCurrentMapName() { return mMapName; }
73
77 int getCurrentTileWidth() const;
78 int getCurrentTileHeight() const;
79
85
86 void videoResized(int width, int height);
87
88 private:
90 bool mDisconnected = false;
91
93
94 Map *mCurrentMap = nullptr;
95 std::string mMapName;
96
98
99 static Game *mInstance;
100};
The main class responsible for running the game.
Definition game.h:37
bool mDisconnected
Definition game.h:90
Map * mCurrentMap
Definition game.h:94
std::string mMapName
Definition game.h:95
int getCurrentTileWidth() const
Convenience functions used to get the current tile width and height.
Definition game.cpp:917
void videoResized(int width, int height)
Definition game.cpp:933
const std::string & getCurrentMapName()
Definition game.h:72
Timer mParticleEngineTimer
Definition game.h:97
Map * getCurrentMap()
Returns the currently active map.
Definition game.h:70
int getCurrentTileHeight() const
Definition game.cpp:925
int mLastTarget
Definition game.h:89
WindowMenu * mWindowMenu
Definition game.h:92
static Game * instance()
Provides access to the game instance.
Definition game.h:53
void handleInput()
Continuous input handling.
Definition game.cpp:708
static Game * mInstance
Definition game.h:99
bool keyDownEvent(SDL_KeyboardEvent &event)
Handles an SDL_KEYDOWN event and returns whether it was consumed.
Definition game.cpp:400
void updateWindowMenuCaptions()
Update the key shortcuts in the window menu.
Definition game.h:83
Game()
Constructs the game, creating all the managers, handlers, engines and GUI windows that make up the ga...
Definition game.cpp:207
void changeMap(const std::string &mapName)
Changes the currently active map.
Definition game.cpp:857
~Game()
Destructor, cleans up the game.
Definition game.cpp:242
void logic()
This method takes the game a small step further.
Definition game.cpp:349
A tile map.
Definition map.h:147
Simple timer that can be used to check if a certain amount of time has passed.
Definition time.h:62
The window menu.
Definition windowmenu.h:42
void updatePopUpCaptions()
Update the pop-up captions with new key shortcuts.