-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththundertool.cpp
More file actions
82 lines (61 loc) · 1.59 KB
/
thundertool.cpp
File metadata and controls
82 lines (61 loc) · 1.59 KB
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
#include "thundertool.h"
#include "gameitem.h"
#include "gamesound.h"
#include "gamebonus.h"
#include "scene_if.h"
ThunderTool::ThunderTool(int x, int y, int score) : GameTool(x,y, score, "cross")
{
bonusInfo = new BonusInfo(1000, myPixmap, tr("Row Blaster"),
tr("Removes all the items in a row"));
}
GameTool::ToolAction ThunderTool::checkItemState(int row, int col)
{
int tr = myToolset->toolRow(), tc = myToolset->toolCol();
PlaceInfo &pi1 = scene->data(tr,tc);
if (pi1.empty())
return ToolOutOfRange;
if (row == tr)
{
PlaceInfo &pi = scene->data(row,col);
if (pi.itemCanBeHighlighted())
{
if (!pi1.itemCanBeHighlighted())
return ToolInactive;
return ToolActive;
}
if (!pi.empty())
return ToolInactive;
}
return ToolOutOfRange;
}
bool ThunderTool::checkItemClick(int row, int col)
{
PlaceInfo &pi = scene->data(row,col);
if (!pi.itemCanBeHighlighted())
return false;
myRow = row;
myProgress = 1;
return true;
}
bool ThunderTool::checkToolClick()
{
if (myProgress >= MAX_COLS)
{
myProgress = 0;
return false;
}
int cx = 5;
for (int j = myProgress-1; j <= myProgress; j++)
{
PlaceInfo &pi = scene->data(myRow,j);
if (pi.itemCanBeHighlighted())
{
scene->removeAndCountItem(myRow,j);
scene->createPixmapPopup(scene->col2x(j), scene->row2y(myRow), 0, cx, myPixmap, 10);
}
cx = -cx;
}
sndEngine->playSound(GameSound::sndRow);
myProgress += 2;
return true;
}