diff options
Diffstat (limited to 'kpacman/energizer.cpp')
-rw-r--r-- | kpacman/energizer.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/kpacman/energizer.cpp b/kpacman/energizer.cpp new file mode 100644 index 0000000..ca08f3b --- /dev/null +++ b/kpacman/energizer.cpp @@ -0,0 +1,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; +} |