-
Notifications
You must be signed in to change notification settings - Fork 0
/
asteroid.h
63 lines (58 loc) · 1.43 KB
/
asteroid.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
#ifndef ASTEROID_H
#define ASTEROID_H
#include <QGraphicsRectItem>
#include <QGraphicsPixmapItem>
class MainWindow;
/**
* Asteroid enemy class. Asteroids shoot off from a random location
* and bounce off the screen.
*/
class Asteroid : public QGraphicsRectItem {
public:
/** Constructor */
Asteroid(double nx, double ny, MainWindow *mw, QGraphicsScene *scene);
/** Destructor */
~Asteroid();
/** Change X */
void setX( int x );
/** Change Y */
void setY( int y );
/** Change velocityX */
void setVelocityX( int vx );
/** Change velocityY */
void setVelocityY( int vy );
/** Deducts life once hit by laser */
bool hit();
/** Accessor for X */
int getX();
/** Accessor for Y */
int getY();
/** Accessor for velocityX */
int getVelocityX();
/** Accessor for velocityY */
int getVelocityY();
/** Move the object */
void move( int windowMaxX, int windowMaxY );
private:
/** Coordinate X */
int x;
/** Coordinate Y */
int y;
/** Rect width */
int width;
/** Rect height */
int height;
/** Object's horizontal speed */
int velocityX;
/** Object's vertical speed */
int velocityY;
/** Amount of lives */
int life;
/** Pointer to parent window */
MainWindow *window;
/** Pointer to parent scene */
QGraphicsScene *scene;
/** Object's image */
QGraphicsPixmapItem *image;
};
#endif