-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.h
70 lines (53 loc) · 1.37 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
//
// Created by lunah on 3/11/2024.
//
#ifndef TANKS_GAME_H
#define TANKS_GAME_H
#include "scene.h"
#include "gamewindow.h"
#include <QObject>
#include <QApplication>
#include <QTimer>
#include <QKeyEvent>
#include <iostream>
class Game : public QApplication{
Q_OBJECT
private:
// Private Variables
GameWindow* gw;
QTimer timer;
int activeKey;
bool inGame;
bool isAlive;
// Private Functions
void pause();
void resume();
void end();
Game(int argc, char** argv);
~Game() override;
static Game* instance;
private slots:
void tick();
public:
/**
* Fetch or construct the game's instance. If you're calling this from main, you
* should pass in argc/argv. Otherwise, they'll be ignored
* @param argc the argument count from main
* @param argv the argument vector from main
* @return the game instance
* @author Tyson Cox
* @date SPRING 2024
*/
static Game* getInstance(int argc = 0, char** argv = nullptr);
/** Should only be called when the game is exiting entirely, just before main's return */
static void destroyInstance();
// Public Functions
int start();
void gameOver();
void wonGame();
void beginNewScene(std::string stateFilename);
GameWindow* getWindow();
public slots:
bool filterKeyEvent(QKeyEvent* event);
};
#endif //TANKS_GAME_H