-
Notifications
You must be signed in to change notification settings - Fork 1
/
monsterRobot.cpp
151 lines (121 loc) · 1.66 KB
/
monsterRobot.cpp
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
138
139
140
141
142
143
144
145
146
147
148
149
150
#include "monsterRobot.h"
#include "monster.h"
#include <iostream>
Robot::Robot(): Monster()
{
xdir = 1;
ydir = 0;
image.load("RobotMonster.png"); //friend's drawing
rect = image.rect();
resetState();
}
Robot::~Robot() {
//std::cout << ("Robot deleted\n");
}
void Robot::autoMove()
{
rect.translate(xdir, ydir);
if (rect.left() <= 0) {
xdir = 1;
setDirection('r');
}
if (rect.right() >= 500) {
xdir = -1;
setDirection('l');
}
if (rect.top() <= 0) {
ydir = 0;
}
if (rect.bottom() >= 600)
{ ydir = 0;
}
}
bool Robot::isShooting()
{
return shooting;
}
void Robot::setShooting(bool shoot)
{
shooting = shoot;
}
char Robot::getDirection()
{
return direction;
}
void Robot::setDirection(char d)
{
direction = d;
}
bool Robot::isDead()
{
return dead;
}
void Robot::setDead(bool d)
{
dead = d;
}
void Robot::resetState()
{
rect.moveTo(0, 505);
direction = 'r';
moving = true;
shooting = true;
appear = false;
dead = false;
}
void Robot::setAppeared(bool a)
{
appear = a;
}
bool Robot::hasAppeared()
{
return appear;
}
void Robot::moveBottom(int bottom)
{
rect.moveBottom(bottom);
}
void Robot::moveTop(int top)
{
rect.moveTop(top);
}
void Robot::moveLeft(int left)
{
rect.moveLeft(left);
}
void Robot::moveRight(int right)
{
rect.moveRight(right);
}
void Robot::setXDir(int x)
{
xdir = x;
}
void Robot::setYDir(int y)
{
ydir = y;
}
int Robot::getXDir()
{
return xdir;
}
int Robot::getYDir()
{
return ydir;
}
void Robot::setMoving(bool m)
{
moving = m;
}
bool Robot::isMoving()
{
return moving;
}
QRect Robot::getRect()
{
return rect;
}
QImage & Robot::getImage()
{
return image;
}