-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.h
137 lines (131 loc) · 3.8 KB
/
mainwindow.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
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QGraphicsRectItem>
#include <QPushButton>
#include <QRadioButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QFormLayout>
#include <QLabel>
#include <vector>
#include <QListWidget>
#include <QLineEdit>
#include <QKeyEvent>
#include <QPointF>
#include <QRectF>
#include <QTimer>
#include "thing.h"
#include "cuttle.h"
#include <QMainWindow>
#include "scores.h"
class GraphicWindow;
#define WINDOW_MAX_X 1000
#define WINDOW_MAX_Y 600
/** MainWindow class is the class that operates as a main method
* and contains and controls everything.
*/
class MainWindow : public QMainWindow {
Q_OBJECT
public:
/** Constructor functions similarly to a main function. Initializes
* the GUI interface*/
explicit MainWindow();
/** Destructor. Removes scene and view*/
~MainWindow();
/** Passed to main(), displays the GUI*/
void show();
/** returns timer*/
QTimer* get_timer(){return timer;}
/** returns game boundaries*/
QRectF* get_bounds(){return bounds;}
/** handles a key being pressed*/
void keyPressEvent(QKeyEvent* e);
/** handles a key being released*/
void keyReleaseEvent(QKeyEvent* e);
/** handles mouse buttons being pressed*/
void mousePressEvent(QMouseEvent* e);
/** handles mouse buttons being released*/
void mouseReleaseEvent(QMouseEvent* e);
private:
/** The graphics scene*/
QGraphicsScene *scene;
/** The graphics view that holds the scene*/
GraphicWindow* view;
/*Main QVBoxLayout. Organizes fields and buttons and display*/
QVBoxLayout *mainVLayout;
/** topmost QHBoxLayout*/
QHBoxLayout* topHLayout;
/** main player : the cuttlefish*/
Cuttle* cuttle;
/** QPointF* for tracking and setting cuttle pos*/
QPointF* cuttlePos;
/** timer for animation and movemet*/
QTimer* timer;
/** boundaries of game*/
QRectF* bounds;
/** vector of all Thing items in game*/
std::vector<Thing*> things;
/** counter to determine levels*/
int level;
/** default pixmap given to each thing */
QPixmap* defaultBMP;
/** weather the cuttlefish is hypnotizing*/
bool hypnosis;
/** whether or not the player is firing(useful for later animations)*/
bool firing;
/** target for firing */
QPoint* target;
/** button to start game*/
QPushButton* start;
/** button to pause game*/
QPushButton* pause;
/** button to see highscores*/
QPushButton* rankings;
/** button to stop playing*/
QPushButton* exit;
/** whether or not game has started*/
bool started;
/** health displaying label*/
QLabel* health;
/** label that shows "GAME OVER"*/
QLabel* gameOver;
/** score displaying label*/
QLabel* score;
/** player's points*/
int points;
/** score multiplier*/
int multiplier;
/** modifies level difficulty*/
int mod;
/** takes and displays player name*/
QFormLayout* player;
/** diisplays "Name"*/
QLabel* name;
/** where player enters name*/
QLineEdit* nameField;
/** returns score in QString format for qlabel score*/
QString getScore();
/** stops game and spams game over*/
void lose();
/** for displaying and writing rankings files*/
Scores* rank;
/** vector of background imags*/
std::vector<QPixmap*> backgrounds;
public slots:
/** animates all the Things*/
void animate();
/** moves all the Things and helps handle collisions*/
void move();
/** Populates the game with Thing items, and updates level*/
void populate();
/** pauses or resumes game*/
void pausePressed();
/** starts game*/
void startPressed();
/** shows rankings*/
void rankingsPressed();
};
#endif // MAINWINDOW_H