aboutsummaryrefslogtreecommitdiff
path: root/AmpelJonas/cPeasant.cpp
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2016-09-25 18:38:34 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2016-09-25 18:38:34 +0200
commit2c12d19204aa198bf8537bcdb137b40f0c7317e9 (patch)
tree2b0ea3e0feb0df50449fdd99e0b1dfa3a2f82c16 /AmpelJonas/cPeasant.cpp
downloadtermgl-2c12d19204aa198bf8537bcdb137b40f0c7317e9.tar.gz
Initial
Diffstat (limited to 'AmpelJonas/cPeasant.cpp')
-rw-r--r--AmpelJonas/cPeasant.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/AmpelJonas/cPeasant.cpp b/AmpelJonas/cPeasant.cpp
new file mode 100644
index 0000000..280c16f
--- /dev/null
+++ b/AmpelJonas/cPeasant.cpp
@@ -0,0 +1,51 @@
+#include "cPeasant.h"
+
+cPeasant::cPeasant(int _direction, int *_phase)
+{
+ pPhase = _phase;
+ iDirection = _direction;
+ pe = new cObject(1, 1);
+ pe->drawPoint(203, sPos{0,0}, true, _COL_YELLOW);
+
+ switch (iDirection)
+ {
+ case _PE_DIR_NORTH:
+ pe->setPosition(_SIZE_X_ / 2 - 7, -1);
+ break;
+ case _PE_DIR_WEST:
+ pe->setPosition(-1, _SIZE_Y_ / 2 - 5);
+ break;
+ }
+}
+
+cPeasant::~cPeasant()
+{
+ delete pe;
+}
+
+cObject *cPeasant::getObject()
+{
+ return pe;
+}
+
+void cPeasant::run()
+{
+ sPos oldPos = pe->getPosition();
+ switch (iDirection)
+ {
+ case _PE_DIR_NORTH:
+ if(!(oldPos.y == _SIZE_Y_ / 2 - 5 && *pPhase != -1))
+ pe->setPosition(oldPos.x, oldPos.y + 1);
+
+ if(oldPos.y > _SIZE_Y_)
+ pe->setPosition(oldPos.x, -1);
+ break;
+ case _PE_DIR_WEST:
+ if (!(oldPos.x == _SIZE_X_ / 2 - 7 && *pPhase != 4))
+ pe->setPosition(oldPos.x + 1, oldPos.y);
+
+ if(oldPos.x > _SIZE_X_)
+ pe->setPosition(-1, oldPos.y);
+ break;
+ }
+} \ No newline at end of file