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