summaryrefslogtreecommitdiff
path: root/src/list.cpp
diff options
context:
space:
mode:
authortom <tom@ground-control>2015-05-08 16:16:59 -0500
committertom <tom@ground-control>2015-05-08 16:16:59 -0500
commit83d23230a3d71d76ee5e0368e071273beaa6d1b4 (patch)
treed617951e5d897ab79efdc061d541c860c2569fd5 /src/list.cpp
parentef2d82b47654dff444263ae149aec0d416a4f405 (diff)
death now works properly
Diffstat (limited to 'src/list.cpp')
-rw-r--r--src/list.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/list.cpp b/src/list.cpp
index ff38a68..6317d45 100644
--- a/src/list.cpp
+++ b/src/list.cpp
@@ -18,7 +18,7 @@ List::List(Window m) //Constructor
L.push_back(Y.getLocation());
}
- main = &m;
+ main = m;
}
void List::Place()
@@ -52,21 +52,23 @@ void List::Behavior()
for(i = 0; i < C.size(); i++)
{
C[i].Behavior(); //executes the behavior of the creature at i
-
+
+ //if the distance between the creature and L[j] is less than 200, insert L[j] into vector Z.
+ for(j = 0; j < L.size(); j++)
+ if(200>(Distance(C[i].getLocation(),L[j])))
+ Z.push_back(L[j]);
+
+ C[i].giveKnown(Z); //sets creature's target location?
+ Z.clear(); //clear vector Z for next creature
+
// This kills the creature
if(C[i].getHealth()==0)
{
Location z = C[i].getLocation();
- R.push_back(Resource(*main,"img/Cdead.png",z));
+ Resource r = Resource(main,"img/Cdead.png",z);
+ R.push_back(r);
C.erase(C.begin()+i);
}
-
- for(j = 0; j < L.size(); j++)
- if(200>(Distance(C[i].getLocation(),L[j]))) //if the distance between the creature and L[j] is less than 200, insert L[j] into vector Z.
- Z.push_back(L[j]);
-
- C[i].giveKnown(Z); //sets creature's target location?
- Z.clear(); //clear vector Z for next creature
}
}