aboutsummaryrefslogtreecommitdiffstats
path: root/YetiHack/src/yeti.cpp
diff options
context:
space:
mode:
authorRay Hogenson <rayhogenson@gmail.com>2012-01-10 15:34:34 -0900
committerRay Hogenson <rayhogenson@gmail.com>2012-01-10 15:34:34 -0900
commit6a4082406f71e40541602473bb0003fe3879fcdd (patch)
tree3fca53b15b55aa2a062d3d5db89ab82d6ebc90b1 /YetiHack/src/yeti.cpp
parentc1d1a4cfb55e87fb4db68980b3af9c31fde363a9 (diff)
downloadyetihack-6a4082406f71e40541602473bb0003fe3879fcdd.tar.zst
Working yetihack
Diffstat (limited to 'YetiHack/src/yeti.cpp')
-rw-r--r--YetiHack/src/yeti.cpp281
1 files changed, 0 insertions, 281 deletions
diff --git a/YetiHack/src/yeti.cpp b/YetiHack/src/yeti.cpp
deleted file mode 100644
index eda9d2c..0000000
--- a/YetiHack/src/yeti.cpp
+++ /dev/null
@@ -1,281 +0,0 @@
-#include "yeti.h"
-#include <cstdlib>
-#include <ctime>
-#include <vector>
-using namespace std;
-void yeti::moveleft()
-{
- --x;
-}
-void yeti::moveright()
-{
- ++x;
-}
-void yeti::moveup()
-{
- --y;
-}
-void yeti::movedown()
-{
- ++y;
-}
-yeti::yeti(int x1, int y1, int sizex1, int sizey1)
-{
- sizex = sizex1;
- sizey = sizey1;
- x = x1;
- y = y1;
-}
-void yeti::movetowards(int a, int b, vector<yeti> yetis, int i)
-{
- int random = rand() % 2;
- int left;
- int right;
- int real;
- if (random == 0)
- {
- left = (x) + (sizex - a);
- right = a + (sizex - x);
- real = absolute(x - a);
- if (left < right && left < real)
- {
- bool empty = true;
- for (int j = 0; j < yetis.size(); ++j)
- {
- int anew = x - 1;
- if (anew > sizex)
- {
- anew = 0;
- }
- if (anew < 1)
- {
- anew = sizex;
- }
- if (i != j && anew == yetis[j].xpos() && yetis[j].ypos() == y)
- {
- empty = false;
- }
- }
- if (empty)
- {
- moveleft();
- }
- }
- else if (right < left && right < real)
- {
- bool empty = true;
- for (int j = 0; j < yetis.size(); ++j)
- {
- int anew = x + 1;
- if (anew > sizex)
- {
- anew = 0;
- }
- if (anew < 1)
- {
- anew = sizex;
- }
- if (i != j && anew == yetis[j].xpos() && yetis[j].ypos() == y)
- {
- empty = false;
- }
- }
- if (empty)
- {
- moveright();
- }
- }
- else
- {
- if (x - a < 0)
- {
- bool empty = true;
- for (int j = 0; j < yetis.size(); ++j)
- {
- int anew = x + 1;
- if (anew > sizex)
- {
- anew = 0;
- }
- if (anew < 1)
- {
- anew = sizex;
- }
- if (i != j && anew == yetis[j].xpos() && yetis[j].ypos() == y)
- {
- empty = false;
- }
- }
- if (empty)
- {
- moveright();
- }
- }
- else if (x - a > 0)
- {
- bool empty = true;
- for (int j = 0; j < yetis.size(); ++j)
- {
- int anew = x - 1;
- if (anew > sizex)
- {
- anew = 0;
- }
- if (anew < 1)
- {
- anew = sizex;
- }
- if (i != j && anew == yetis[j].xpos() && yetis[j].ypos() == y)
- {
- empty = false;
- }
- }
- if (empty)
- {
- moveleft();
- }
- }
- }
- }
- // now for b
- else
- {
- left = (y) + (sizey - b);
- right = b + (sizey - y);
- real = absolute(y - b);
- if (left < right && left < real)
- {
- bool empty = true;
- for (int j = 0; j < yetis.size(); ++j)
- {
- int bnew = y - 1;
- if (bnew > sizey)
- {
- bnew = 0;
- }
- if (bnew < 1)
- {
- bnew = sizey;
- }
- if (i != j && x == yetis[j].xpos() && yetis[j].ypos() == bnew)
- {
- empty = false;
- }
- }
- if (empty)
- {
- moveup();
- }
- }
- else if (right < left && right < real)
- {
- bool empty = true;
- for (int j = 0; j < yetis.size(); ++j)
- {
- int bnew = y + 1;
- if (bnew > sizey)
- {
- bnew = 0;
- }
- if (bnew < 1)
- {
- bnew = sizey;
- }
- if (i != j && x == yetis[j].xpos() && yetis[j].ypos() == bnew)
- {
- empty = false;
- }
- }
- if (empty)
- {
- movedown();
- }
- }
- else
- {
- if (y - b < 0)
- {
- bool empty = true;
- for (int j = 0; j < yetis.size(); ++j)
- {
- int bnew = y + 1;
- if (bnew > sizey)
- {
- bnew = 0;
- }
- if (bnew < 1)
- {
- bnew = sizey;
- }
- if (i != j && x == yetis[j].xpos() && yetis[j].ypos() == bnew)
- {
- empty = false;
- }
- }
- if (empty)
- {
- movedown();
- }
- }
- else if (y - b > 0)
- {
- bool empty = true;
- for (int j = 0; j < yetis.size(); ++j)
- {
- int bnew = y - 1;
- if (bnew > sizey)
- {
- bnew = 0;
- }
- if (bnew < 1)
- {
- bnew = sizey;
- }
- if (i != j && x == yetis[j].xpos() && yetis[j].ypos() == bnew)
- {
- empty = false;
- }
- }
- if (empty)
- {
- moveup();
- }
- }
- }
- }
- // deal with going off the side
- if (x < 1)
- {
- x = sizex;
- }
- if (x > sizex)
- {
- x = 1;
- }
- if (y < 1)
- {
- y = sizey;
- }
- if (y > sizey)
- {
- y = 1;
- }
-}
-
-int yeti::xpos()
-{
- return x;
-}
-int yeti::ypos()
-{
- return y;
-}
-int yeti::absolute(int value)
-{
- if (value < 0)
- {
- value = 0 - value;
- }
- return value;
-}
-