summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortom <tom@ground-control>2015-11-25 16:05:41 -0600
committertom <tom@ground-control>2015-11-25 16:05:41 -0600
commit260589abf40d3a0d02c5c472467858cc4c151e6a (patch)
tree86a96732d89a3a373aa846617fb0ea7f4a334800
parent0fb714b1a642361eebadf7d74333c20f861354d2 (diff)
allowed movement ordersHEADmaster
-rw-r--r--inc/Character.hpp4
-rw-r--r--inc/List.hpp1
-rw-r--r--src/List.cpp6
-rw-r--r--src/main.cpp6
4 files changed, 13 insertions, 4 deletions
diff --git a/inc/Character.hpp b/inc/Character.hpp
index 3c88ab2..f519c3f 100644
--- a/inc/Character.hpp
+++ b/inc/Character.hpp
@@ -23,9 +23,9 @@ class Character
void wander(vector <Character> men, vector <Location> impassable);
Location getLocation(){return l;}
char getSymbol(){return symbol;}
-
+ void giveOrder(Location L){d = L;order="move";}
private:
- string order = "move";
+ string order = "wander";
Location l; // current location
Location d; // destination
char symbol;
diff --git a/inc/List.hpp b/inc/List.hpp
index 447903b..56d25e9 100644
--- a/inc/List.hpp
+++ b/inc/List.hpp
@@ -14,6 +14,7 @@ class List
List(vector <Location> i);
void draw(WINDOW * w);
void action();
+ void order(Location l);
private:
vector <Character> men;
vector <Location> impassable;
diff --git a/src/List.cpp b/src/List.cpp
index bd0f5d4..86049a3 100644
--- a/src/List.cpp
+++ b/src/List.cpp
@@ -24,3 +24,9 @@ void List::action()
for(int i = 0; i < men.size(); i++)
men[i].action(men,impassable);
}
+
+void List::order(Location l)
+{
+ for(int i = 0; i < men.size(); i++)
+ men[i].giveOrder(l);
+}
diff --git a/src/main.cpp b/src/main.cpp
index 75847a2..1588dbd 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -20,7 +20,7 @@ int main()
while(true)
{
char c = getch();
- Location l = cursor.getLocation();
+ l = cursor.getLocation();
if (c == 'h')
l.y = l.y-1;
else if (c == 'l')
@@ -32,7 +32,9 @@ int main()
else if (c == 'q')
break;
else if (c == 'p')
- paused = !paused;
+ paused = !paused;
+ else if (c == 'o')
+ L.order(l);
cursor.move(l);
if (!paused)