summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortom <tom@ground-control>2015-11-23 20:34:06 -0600
committertom <tom@ground-control>2015-11-23 20:34:06 -0600
commit1031174ed7446d22b3f5505ff3a4e84135b88cc3 (patch)
treeaf3a4ec1f990093017927eebb4a21a145835c6ca /src
parent9d9c1d29dbcd802c89641b70b5574361e775c0e4 (diff)
refracter
Diffstat (limited to 'src')
-rw-r--r--src/Character.cpp68
1 files changed, 41 insertions, 27 deletions
diff --git a/src/Character.cpp b/src/Character.cpp
index 24ed475..8102b4c 100644
--- a/src/Character.cpp
+++ b/src/Character.cpp
@@ -16,33 +16,9 @@ void Character::draw(WINDOW * w)
void Character::action(vector <Character> men, vector <Location> impassable)
{
if(order == "wander")
- {
- int r = rand()%15+1;
- bool stay = false;
- Location L;
- if(r==1)
- L = Location(l.x+1,l.y);
- else if(r==2)
- L = Location(l.x-1,l.y);
- else if(r==3)
- L = Location(l.x,l.y+1);
- else if(r==4)
- L = Location(l.x,l.y-1);
- else if(r==5)
- L = Location(l.x+1,l.x+1);
- else if(r==6)
- L = Location(l.x-1,l.y-1);
- else if(r==7)
- L = Location(l.x+1,l.y-1);
- else if(r==8)
- L = Location(l.x-1,l.y+1);
- else
- stay = true;
-
- if (!stay)
- if(check(L,men,impassable))
- move(L);
- }
+ wander(men, impassable);
+ else if(order == "move")
+ astar(men,impassable);
}
bool Character::check(Location L, vector <Character> men, vector <Location> impassable)
@@ -57,3 +33,41 @@ bool Character::check(Location L, vector <Character> men, vector <Location> impa
return true;
}
+
+void Character::wander(vector <Character> men, vector <Location> impassable)
+{
+ int r = rand()%15+1;
+ bool stay = false;
+ Location L;
+ if(r==1)
+ L = Location(l.x+1,l.y);
+ else if(r==2)
+ L = Location(l.x-1,l.y);
+ else if(r==3)
+ L = Location(l.x,l.y+1);
+ else if(r==4)
+ L = Location(l.x,l.y-1);
+ else if(r==5)
+ L = Location(l.x+1,l.x+1);
+ else if(r==6)
+ L = Location(l.x-1,l.y-1);
+ else if(r==7)
+ L = Location(l.x+1,l.y-1);
+ else if(r==8)
+ L = Location(l.x-1,l.y+1);
+ else
+ stay = true;
+
+ if (!stay)
+ if(check(L,men,impassable))
+ move(L);
+}
+
+void Character::astar(vector <Character> men, vector <Location> impassable)
+{
+ vector <Location> closed;
+ vector <Location> open;
+
+
+
+}