-
Notifications
You must be signed in to change notification settings - Fork 1
/
consttools.cpp
152 lines (120 loc) · 4.11 KB
/
consttools.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
151
152
#include "consttools.h"
#include "gamesound.h"
#include "gamewidget.h"
#include "gamestock.h"
#include "gamebonus.h"
#include "scene_if.h"
////////////////////////////////////////////////////////////////////////////////
ConstBonus::ConstBonus(int x, int y, int score, const QString &resource) :
GameTool(x,y,score),
bonusValue(0)
{
myPixmap = QPixmap(GameWidget::getResourcePath() + "/bonus/" + resource + ".png")
.scaled(X48,Y48, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
smallPixmap = myPixmap.scaled(DX(16),DY(16), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
////////////////////////////////////////////////////////////////////////////////
// this increases bonus timer
TimerBonus::TimerBonus(int x, int y, int score) : ConstBonus(x,y, score, "timer")
{
bonusInfo = new BonusInfo(tr("Score-Time Bonus"),
tr("Gives +1 extra second for every score-time bonus"));
}
bool TimerBonus::checkToolClick()
{
bonusValue += 2;
scene->createPixmapPopup(DX(980),DY(160), 0,-1, myPixmap, 20);
sndEngine->playSound(GameSound::sndBonusGot);
return true;
}
void TimerBonus::advanceAndPaint(QPainter &p, int currentScore)
{
if (bonusValue)
{
p.setOpacity(1);
p.setPen(Qt::white);
p.setFont(gameStock->Font8);
p.drawPixmap(DX(1000),DY(140), smallPixmap);
p.drawText(DX(975),DY(140), DX(25),DY(20), Qt::AlignRight, QString("+%1").arg(bonusValue));
}
GameTool::advanceAndPaint(p, currentScore);
}
////////////////////////////////////////////////////////////////////////////////
// this increases magnifier
MagBonus::MagBonus(int x, int y, int score) : ConstBonus(x,y, score, "x")
{
bonusInfo = new BonusInfo(tr("Score-Magnification Bonus"),
tr("Increases score magnifier by 1"));
}
bool MagBonus::checkToolClick()
{
bonusValue += 1;
scene->createPixmapPopup(DX(980),DY(160), 0,-1, myPixmap, 20);
sndEngine->playSound(GameSound::sndBonusGot);
return true;
}
void MagBonus::advanceAndPaint(QPainter &p, int currentScore)
{
if (bonusValue > 2)
{
p.setOpacity(1);
p.setPen(Qt::white);
p.setFont(gameStock->Font8);
p.drawPixmap(DX(1000),DY(160), smallPixmap);
p.drawText(DX(975),DY(160), DX(25),DY(20), Qt::AlignRight, QString("x%1").arg(bonusValue));
}
GameTool::advanceAndPaint(p, currentScore);
}
////////////////////////////////////////////////////////////////////////////////
// this gives +1 to score
ScoreBonus::ScoreBonus(int x, int y, int score) : ConstBonus(x,y, score, "score")
{
bonusInfo = new BonusInfo(tr("Score Bonus"),
tr("Gives +1 extra point for every destroyed target"));
}
bool ScoreBonus::checkToolClick()
{
bonusValue += 1;
scene->createPixmapPopup(DX(980),DY(10), 0,-1, myPixmap, 20);
sndEngine->playSound(GameSound::sndBonusGot);
return true;
}
void ScoreBonus::advanceAndPaint(QPainter &p, int currentScore)
{
if (bonusValue)
{
p.setOpacity(1);
p.setPen(Qt::white);
p.setFont(gameStock->Font8);
p.drawPixmap(DX(1000),DY(10), smallPixmap);
p.drawText(DX(975),DY(10), DX(25),DY(20), Qt::AlignRight, QString("+%1").arg(bonusValue));
}
GameTool::advanceAndPaint(p, currentScore);
}
////////////////////////////////////////////////////////////////////////////////
// this increases time for level
ClockBonus::ClockBonus(int x, int y, int score) : ConstBonus(x,y, score, "clock")
{
bonusInfo = new BonusInfo(tr("Time Bonus"),
tr("Gives +30 extra seconds for every level"));
}
bool ClockBonus::checkToolClick()
{
bonusValue += 30;
scene->createPixmapPopup(DX(980),DY(60), 0,-1, myPixmap, 20);
sndEngine->playSound(GameSound::sndBonusGot);
return true;
}
void ClockBonus::advanceAndPaint(QPainter &p, int currentScore)
{
if (bonusValue)
{
p.setOpacity(1);
p.setPen(Qt::white);
p.setFont(gameStock->Font8);
p.drawPixmap(DX(1000),DY(60), smallPixmap);
p.drawText(DX(975),DY(60), DX(25),DY(20), Qt::AlignRight, QString("+%1").arg(bonusValue));
}
GameTool::advanceAndPaint(p, currentScore);
}
////////////////////////////////////////////////////////////////////////////////