1 #include "consttools.h"
2 #include "gamesound.h"
3 #include "gamewidget.h"
4 #include "gamestock.h"
5 #include "gamebonus.h"
6 #include "scene_if.h"
7 
8 ////////////////////////////////////////////////////////////////////////////////
9 
ConstBonus(int x,int y,int score,const QString & resource)10 ConstBonus::ConstBonus(int x, int y, int score, const QString &resource) :
11     GameTool(x,y,score),
12     bonusValue(0)
13 {
14   myPixmap = QPixmap(GameWidget::getResourcePath() + "/bonus/" + resource + ".png")
15              .scaled(X48,Y48, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
16 
17   smallPixmap = myPixmap.scaled(DX(16),DY(16), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
18 }
19 
20 ////////////////////////////////////////////////////////////////////////////////
21 
22 // this increases bonus timer
TimerBonus(int x,int y,int score)23 TimerBonus::TimerBonus(int x, int y, int score) : ConstBonus(x,y, score, "timer")
24 {
25   bonusInfo = new BonusInfo(tr("Score-Time Bonus"),
26                             tr("Gives +1 extra second for every score-time bonus"));
27 }
28 
checkToolClick()29 bool TimerBonus::checkToolClick()
30 {
31   bonusValue += 2;
32   scene->createPixmapPopup(DX(980),DY(160), 0,-1, myPixmap, 20);
33 
34   sndEngine->playSound(GameSound::sndBonusGot);
35   return true;
36 }
37 
advanceAndPaint(QPainter & p,int currentScore)38 void TimerBonus::advanceAndPaint(QPainter &p, int currentScore)
39 {
40   if (bonusValue)
41   {
42     p.setOpacity(1);
43     p.setPen(Qt::white);
44     p.setFont(gameStock->Font8);
45 
46     p.drawPixmap(DX(1000),DY(140), smallPixmap);
47     p.drawText(DX(975),DY(140), DX(25),DY(20), Qt::AlignRight, QString("+%1").arg(bonusValue));
48   }
49 
50     GameTool::advanceAndPaint(p, currentScore);
51 }
52 
53 ////////////////////////////////////////////////////////////////////////////////
54 
55 // this increases magnifier
MagBonus(int x,int y,int score)56 MagBonus::MagBonus(int x, int y, int score) : ConstBonus(x,y, score, "x")
57 {
58   bonusInfo = new BonusInfo(tr("Score-Magnification Bonus"),
59                             tr("Increases score magnifier by 1"));
60 }
61 
checkToolClick()62 bool MagBonus::checkToolClick()
63 {
64   bonusValue += 1;
65   scene->createPixmapPopup(DX(980),DY(160), 0,-1, myPixmap, 20);
66 
67   sndEngine->playSound(GameSound::sndBonusGot);
68   return true;
69 }
70 
advanceAndPaint(QPainter & p,int currentScore)71 void MagBonus::advanceAndPaint(QPainter &p, int currentScore)
72 {
73   if (bonusValue > 2)
74   {
75     p.setOpacity(1);
76     p.setPen(Qt::white);
77     p.setFont(gameStock->Font8);
78 
79     p.drawPixmap(DX(1000),DY(160), smallPixmap);
80     p.drawText(DX(975),DY(160), DX(25),DY(20), Qt::AlignRight, QString("x%1").arg(bonusValue));
81   }
82 
83    GameTool::advanceAndPaint(p, currentScore);
84 }
85 
86 ////////////////////////////////////////////////////////////////////////////////
87 
88 // this gives +1 to score
ScoreBonus(int x,int y,int score)89 ScoreBonus::ScoreBonus(int x, int y, int score) : ConstBonus(x,y, score, "score")
90 {
91   bonusInfo = new BonusInfo(tr("Score Bonus"),
92                             tr("Gives +1 extra point for every destroyed target"));
93 }
94 
checkToolClick()95 bool ScoreBonus::checkToolClick()
96 {
97   bonusValue += 1;
98   scene->createPixmapPopup(DX(980),DY(10), 0,-1, myPixmap, 20);
99 
100   sndEngine->playSound(GameSound::sndBonusGot);
101   return true;
102 }
103 
advanceAndPaint(QPainter & p,int currentScore)104 void ScoreBonus::advanceAndPaint(QPainter &p, int currentScore)
105 {
106   if (bonusValue)
107   {
108     p.setOpacity(1);
109     p.setPen(Qt::white);
110     p.setFont(gameStock->Font8);
111 
112     p.drawPixmap(DX(1000),DY(10), smallPixmap);
113     p.drawText(DX(975),DY(10), DX(25),DY(20), Qt::AlignRight, QString("+%1").arg(bonusValue));
114   }
115 
116     GameTool::advanceAndPaint(p, currentScore);
117 }
118 
119 ////////////////////////////////////////////////////////////////////////////////
120 
121 // this increases time for level
ClockBonus(int x,int y,int score)122 ClockBonus::ClockBonus(int x, int y, int score) : ConstBonus(x,y, score, "clock")
123 {
124   bonusInfo = new BonusInfo(tr("Time Bonus"),
125                             tr("Gives +30 extra seconds for every level"));
126 }
127 
checkToolClick()128 bool ClockBonus::checkToolClick()
129 {
130   bonusValue += 30;
131   scene->createPixmapPopup(DX(980),DY(60), 0,-1, myPixmap, 20);
132 
133   sndEngine->playSound(GameSound::sndBonusGot);
134   return true;
135 }
136 
advanceAndPaint(QPainter & p,int currentScore)137 void ClockBonus::advanceAndPaint(QPainter &p, int currentScore)
138 {
139   if (bonusValue)
140   {
141     p.setOpacity(1);
142     p.setPen(Qt::white);
143     p.setFont(gameStock->Font8);
144 
145     p.drawPixmap(DX(1000),DY(60), smallPixmap);
146     p.drawText(DX(975),DY(60), DX(25),DY(20), Qt::AlignRight, QString("+%1").arg(bonusValue));
147   }
148 
149     GameTool::advanceAndPaint(p, currentScore);
150 }
151 
152 ////////////////////////////////////////////////////////////////////////////////
153