Diffstat (limited to 'noncore/games/kpacman/energizer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/kpacman/energizer.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/noncore/games/kpacman/energizer.cpp b/noncore/games/kpacman/energizer.cpp new file mode 100644 index 0000000..ca08f3b --- a/dev/null +++ b/noncore/games/kpacman/energizer.cpp | |||
@@ -0,0 +1,61 @@ | |||
1 | #include "energizer.h" | ||
2 | |||
3 | Energizer::Energizer(Board *b) | ||
4 | { | ||
5 | board = b; | ||
6 | setOn(); | ||
7 | actualPosition = OUT; | ||
8 | maxPixmaps = 0; | ||
9 | } | ||
10 | |||
11 | void Energizer::setMaxPixmaps(int max) | ||
12 | { | ||
13 | maxPixmaps = max; | ||
14 | } | ||
15 | |||
16 | void Energizer::setOff() | ||
17 | { | ||
18 | actualState = off; | ||
19 | } | ||
20 | |||
21 | void Energizer::setOn() | ||
22 | { | ||
23 | actualState = on; | ||
24 | actualPix = 0; | ||
25 | } | ||
26 | |||
27 | void Energizer::setPosition(int pos) | ||
28 | { | ||
29 | board->reset(actualPosition, energizer); | ||
30 | actualPosition = pos; | ||
31 | board->set(actualPosition, energizer); | ||
32 | } | ||
33 | |||
34 | energizerState Energizer::state() | ||
35 | { | ||
36 | return actualState; | ||
37 | } | ||
38 | |||
39 | int Energizer::position() | ||
40 | { | ||
41 | return actualPosition; | ||
42 | } | ||
43 | |||
44 | bool Energizer::move() | ||
45 | { | ||
46 | if (actualPosition == OUT) | ||
47 | return FALSE; | ||
48 | |||
49 | if (++actualPix >= maxPixmaps) | ||
50 | actualPix = 0; | ||
51 | |||
52 | return TRUE; | ||
53 | } | ||
54 | |||
55 | int Energizer::pix() | ||
56 | { | ||
57 | if (actualPosition == OUT || actualState == off) | ||
58 | return -1; | ||
59 | |||
60 | return actualPix; | ||
61 | } | ||