-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpredatorrobot.cpp
58 lines (53 loc) · 1.82 KB
/
predatorrobot.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
#include "predatorrobot.h"
CPredatorRobot::CPredatorRobot()
{
hp = 300;
multiTarget = true;
power = 90;
pr.gold = 90;
pr.rhodium = 30;
pr.platinum = 60;
model = Predator;
}
CPredatorRobot::~CPredatorRobot()
{
}
QPixmap CPredatorRobot::draw(int color, int dir)
{
QMap<int, QPixmap> robot;
QMap<int, QPixmap> light;
QMap<int, QPixmap> gun;
QPixmap shadow;
robot[Cyan] = QPixmap("./images/bot4/bot4");
robot[Magenta] = QPixmap("./images/bot4/bot4");
robot[Red] = QPixmap("./images/bot4/bot4");
robot[Yellow] = QPixmap("./images/bot4/bot4");
gun[Yellow] = QPixmap("./images/bot4/gun4yellow");
gun[Red] = QPixmap("./images/bot4/gun4red");
gun[Cyan] = QPixmap("./images/bot4/gun4blue");
gun[Magenta] = QPixmap("./images/bot4/gun4pink");
light[Red] = QPixmap("./images/bot4/red4");
light[Cyan] = QPixmap("./images/bot4/blue4");
light[Yellow] = QPixmap("./images/bot4/yellow4");
light[Magenta] = QPixmap("./images/bot4/pink4");
shadow = QPixmap("./images/bot4/shadow4");
QPixmap output(360,360);
output.fill(Qt::transparent);
QPainter painter(&output);
painter.setRenderHint(QPainter::Antialiasing);
painter.drawPixmap(0,0,light[color]);
painter.drawPixmap(0,0,robot[color]);
painter.drawPixmap(111,105,gun[color]);
QTransform t(1, 0, 0, 1, output.width()/2, output.height()/2);
t.rotate(dir*(360/6));
QPixmap tempOutput(450,450);
tempOutput.fill(Qt::transparent);
QPainter p(&tempOutput);
p.drawPixmap(50,20,shadow.transformed(t));
p.drawPixmap(0,0,output.transformed(t));
return tempOutput.copy(abs(sin(dir*(360/6)*_DEG2RAD)*40),abs(cos(dir*(360/6)*_DEG2RAD)*40),450-abs(sin(dir*(360/6)*_DEG2RAD)*40),450-abs(cos(dir*(360/6)*_DEG2RAD)*40)).scaled(360, 360);
}
int CPredatorRobot::hit()
{
return power;
}