-
Notifications
You must be signed in to change notification settings - Fork 1
/
medium_mode.h
107 lines (83 loc) · 2.77 KB
/
medium_mode.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
#ifndef MEDIUM_MODE_H
#define MEDIUM_MODE_H
#include <QWidget>
#include <QPaintEvent>
#include <QPoint>
#include <QSize>
#include <QTimer>
#include <QPixmap>
namespace Ui {
class medium_mode;
}
/** Class: medium_mode
*
* Brief: Builds off the QWidget class. Purpose of this class is to display the medium mode of the game.
* In medium mode, the basket and ball move at a medium pace. The player has 60 seconds to score as many
* points as possible into the basket. However, unlike medium mode, the player must also avoid hitting a
* defender in medium mode. When the ball hits the defender, the player's ball is reset and no points are
* added to the total score. When time expires, the player will be shipped back to the starting screen.
*
*/
class medium_mode : public QWidget
{
Q_OBJECT
public:
// easy_mode constructor
explicit medium_mode(QWidget *parent = 0);
// easy_mode destructor
~medium_mode();
// easy_mode paint event
void paintEvent(QPaintEvent* e);
// easy_mode keyPressEvent (inherited from widget)
void keyPressEvent(QKeyEvent* event);
// easy_mode showEvent function
void showEvent(QShowEvent* event);
// is_ball_in_hoop function
bool is_ball_in_hoop();
// displays our points onto the screen
void display_points();
public slots:
// animates the hoop left and right (i.e. changes the position, then calls repaint())
void animate_hoop();
// ball animation function
void animate_ball();
// animates the defender
void animate_defender();
// display time remaining
void display_time_remaining();
private:
Ui::medium_mode *ui;
// general variables
size_t screen_width;
size_t screen_height;
const size_t x_change_per_press = 100;
QPixmap* background_image;
size_t time_remaining = 60;
size_t points = 0;
// timers
QTimer* hoop_and_ball_and_defender_timer;
QTimer* shot_clock;
QTimer* shot_clock_per_second;
// baller variables
QPoint* baller_position;
QSize* baller_size; //we will grab necessary data in the constructor
QPixmap* baller_image;
// defender variables
QPoint* defender_position;
QSize* defender_size;
QPixmap* defender_image;
int defender_change_per_timeout = 40;
// hoop variables
QPoint* hoop_position;
QSize* hoop_size;
QPixmap* hoop_image;
int hoop_change_per_timeout = 20; // want to be able to change this everytime we hit a side wall...
// ball variabes
QPoint* ball_position;
QSize* ball_size;
QPixmap* ball_image;
bool ball_in_motion = false;
size_t ball_default_height;
const int ball_change_per_timeout = 40;
};
#endif // MEDIUM_MODE_H