summaryrefslogtreecommitdiff
path: root/noncore/games/kpacman/energizer.cpp
blob: ca08f3bb36b550645d61b7a5074ce4169cf93288 (plain)
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
#include "energizer.h"

Energizer::Energizer(Board *b)
{
    board = b;
    setOn();
    actualPosition = OUT;
    maxPixmaps = 0;
}

void Energizer::setMaxPixmaps(int max)
{
    maxPixmaps = max;
}

void Energizer::setOff()
{
    actualState = off;
}

void Energizer::setOn()
{
    actualState = on;
    actualPix = 0;
}

void Energizer::setPosition(int pos)
{
    board->reset(actualPosition, energizer);
    actualPosition = pos;
    board->set(actualPosition, energizer);
}

energizerState Energizer::state()
{
    return actualState;
}

int Energizer::position()
{
    return actualPosition;
}

bool Energizer::move()
{
    if (actualPosition == OUT)
        return FALSE;

    if (++actualPix >= maxPixmaps)
        actualPix = 0;

    return TRUE;
}

int Energizer::pix()
{
    if (actualPosition == OUT || actualState == off)
        return -1;

    return actualPix;
}