6 #include <QOpenGLFunctions>
36 class Game :
public QQuickItem
50 Game(const Game & other) = delete;
55 Game & operator=(const Game & other) = delete;
87 void createWorld(
bool isNetworkGame,
bool isPlayerOne,
int terrainSeed);
89 void endGame(
bool localPlayerWins,
bool showMessage);
114 Q_INVOKABLE
void keyInput(Qt::Key key);
119 Q_INVOKABLE
void moveInput(
int type, qreal x, qreal y);
120 Q_INVOKABLE
void touchInput(qreal oldx, qreal oldy, qreal x, qreal y);
void connectSignals(QQuickWindow *win)
Definition: game.cpp:244
Timer & timer()
Definition: game.cpp:133
void toggleUI()
Hide or show the UI.
Definition: game.cpp:90
NetworkManager m_networkManager
Definition: game.h:179
QOpenGLFunctions m_gl
Definition: game.h:187
Q_INVOKABLE void joinNetworkGame(QString host)
Try to connect to the given host and receive game information.
Definition: game.cpp:55
Q_INVOKABLE void buttonInput(int type)
Handle a pressed button event from the UI.
Definition: game.cpp:138
The Timer class implements a set of pauseable duration counters (subsequently called timers) and mech...
Definition: timer.h:18
const unsigned short defaultPort
Definition: game.h:23
The Game class is the main entry point. It subclasses QQuickItem and handles all communication betwee...
Definition: game.h:36
bool isPaused()
Definition: game.h:162
Q_INVOKABLE void startLocalGame()
Sets up a local game against an AI player with the local plaer being the one on the right...
Definition: game.cpp:44
Q_INVOKABLE void moveInput(int type, qreal x, qreal y)
Handle a mouse move event.
Definition: game.cpp:154
void sync()
Update game world, taking elapsed time into account.
Definition: game.cpp:170
ActionScheduler & scheduler()
Definition: game.cpp:123
void setPaused(bool paused)
Pause or continue ingame time.
Definition: game.cpp:233
void disconnectSignals()
Definition: game.cpp:255
The EventHandler class receives events (touch, key, mouse, gyroscope, etc.) and triggers actions...
Definition: eventhandler.h:14
void showUI()
Definition: game.cpp:102
bool isPaused()
Definition: timer.cpp:51
bool m_isGLInitialized
The timer that triggers a redraw.
Definition: game.h:186
Q_INVOKABLE void hostNetworkGame()
Start a paused game and wait for a connecting player.
Definition: game.cpp:49
The NetworkManager implements the basic functionality for the multiplayer mode of this game...
Definition: networkmanager.h:28
std::unique_ptr< World > m_world
Definition: game.h:192
Timer m_timer
Definition: game.h:176
void togglePaused()
Definition: game.cpp:238
EventHandler m_eventHandler
Definition: game.h:177
void createWorld(bool isNetworkGame, bool isPlayerOne, int terrainSeed)
Generic method to create a World.
Definition: game.cpp:60
NetworkManager & networkManager()
Definition: game.cpp:128
The World class represents a running game instance and contains all graphical (3D) elements of the sc...
Definition: world.h:46
std::unique_ptr< QTimer > m_renderTrigger
Definition: game.h:185
void handleWindowChanged(QQuickWindow *win)
Handles a change of the QQuickWindow.
Definition: game.cpp:220
void updateQMLData()
Update the data storage used by the UI to display game info.
Definition: game.cpp:268
bool m_isUIActive
Definition: game.h:190
Definition: eventhandler.cpp:18
World & world() const
Definition: game.cpp:117
void hideUI()
Definition: game.cpp:110
Q_INVOKABLE void touchInput(qreal oldx, qreal oldy, qreal x, qreal y)
Definition: game.cpp:162
void endGame(bool localPlayerWins, bool showMessage)
Definition: game.cpp:69
ActionScheduler m_scheduler
Definition: game.h:178
bool m_isPlayerOne
Definition: game.h:189
void render()
Render game world.
Definition: game.cpp:201
Q_INVOKABLE void keyInput(Qt::Key key)
Handle a key event.
Definition: game.cpp:146
QQuickWindow * m_window
Definition: game.h:184
The ActionScheduler class maintains a list of actions, that should be executed later in a specific co...
Definition: actionscheduler.h:16
void cleanup()
Definition: game.cpp:215
QVariant m_qmlData
Definition: game.h:182