1 #include "gametargets.h"
2 #include "gameitem.h"
3 #include "gamestock.h"
4 
5 ////////////////////////////////////////////////////////////////////////////////
6 
7 QPixmap* GameBasicTarget::pixOn = 0;
8 QPixmap* GameBasicTarget::pixOff = 0;
9 
GameBasicTarget()10 GameBasicTarget::GameBasicTarget() : GameTarget(pixOn, pixOff)
11 {
12 }
13 
init()14 void GameBasicTarget::init()
15 {
16   GameTarget::init("base", &pixOn, &pixOff);
17 }
18 
19 ////////////////////////////////////////////////////////////////////////////////
20 
21 QPixmap* GameNumberTarget::pixOn = 0;
22 QPixmap* GameNumberTarget::pixOff = 0;
23 
GameNumberTarget(int id)24 GameNumberTarget::GameNumberTarget(int id) : GameTarget(pixOn, pixOff), myId(id)
25 {
26 }
27 
init()28 void GameNumberTarget::init()
29 {
30   GameTarget::init("number", &pixOn, &pixOff);
31 }
32 
repaint()33 void GameNumberTarget::repaint()
34 {
35   GameTarget::repaint();
36 
37   QPainter p(&myPixmapBuffer);
38   p.setPen(Qt::white);
39   p.setFont(gameStock->Font20);
40   p.setOpacity(0.8);
41   p.drawText(0,0,myPixmapBuffer.width(),myPixmapBuffer.height(),
42              Qt::AlignCenter, QString("%1").arg(myId));
43   p.end();
44 }
45 
checkChain(int size,int id,int score)46 GameTarget::CheckResult GameNumberTarget::checkChain(int size, int id, int score)
47 {
48   if (size >= myId)
49   {
50     return GameTarget::checkChain(size,id,score);
51   }
52 
53   return Ignored;
54 }
55 
56 ////////////////////////////////////////////////////////////////////////////////
57 
58 QPixmap* GameColorTarget::pixOn[6] = {0};
59 QPixmap* GameColorTarget::pixOff[6] = {0};
60 
GameColorTarget(int id)61 GameColorTarget::GameColorTarget(int id) :
62     GameTarget(pixOn[id], pixOff[id]),
63     myId(id)
64 {
65 }
66 
init()67 void GameColorTarget::init()
68 {
69   GameTarget::init("blue", &pixOn[0], &pixOff[0]);
70   GameTarget::init("yellow", &pixOn[1], &pixOff[1]);
71   GameTarget::init("red", &pixOn[2], &pixOff[2]);
72   GameTarget::init("green", &pixOn[3], &pixOff[3]);
73   GameTarget::init("magenta", &pixOn[4], &pixOff[4]);
74   GameTarget::init("cyan", &pixOn[5], &pixOff[5]);
75 }
76 
checkChain(int size,int id,int score)77 GameTarget::CheckResult GameColorTarget::checkChain(int size, int id, int score)
78 {
79   if (id == myId)
80   {
81     return GameTarget::checkChain(size,id,score);
82   }
83 
84   return Ignored;
85 }
86 
87 ////////////////////////////////////////////////////////////////////////////////
88 
89 QPixmap* GameFallTarget::pixOn = 0;
90 QPixmap* GameFallTarget::pixOff = 0;
91 
GameFallTarget()92 GameFallTarget::GameFallTarget() : GameTarget(pixOn, pixOff, FALLER_SCORE)
93 {
94 }
95 
~GameFallTarget()96 GameFallTarget::~GameFallTarget()
97 {
98 }
99 
init()100 void GameFallTarget::init()
101 {
102   GameTarget::init("faller", &pixOn, &pixOff);
103 }
104 
checkChain(int size,int id,int score)105 GameTarget::CheckResult GameFallTarget::checkChain(int size, int id, int score)
106 {
107   if (id != ITEM_FALLER)
108     return Ignored;
109 
110   return GameTarget::checkChain(size,id,score);
111 }
112