From 83d23230a3d71d76ee5e0368e071273beaa6d1b4 Mon Sep 17 00:00:00 2001 From: tom Date: Fri, 8 May 2015 16:16:59 -0500 Subject: death now works properly --- src/list.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src/list.cpp') 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 } } -- cgit v1.2.3