diff options
author | tom <tom@ground-control> | 2015-05-08 16:16:59 -0500 |
---|---|---|
committer | tom <tom@ground-control> | 2015-05-08 16:16:59 -0500 |
commit | 83d23230a3d71d76ee5e0368e071273beaa6d1b4 (patch) | |
tree | d617951e5d897ab79efdc061d541c860c2569fd5 /src | |
parent | ef2d82b47654dff444263ae149aec0d416a4f405 (diff) |
death now works properly
Diffstat (limited to 'src')
-rw-r--r-- | src/creature.cpp | 2 | ||||
-rw-r--r-- | src/list.cpp | 22 | ||||
-rw-r--r-- | src/resource.cpp | 8 |
3 files changed, 16 insertions, 16 deletions
diff --git a/src/creature.cpp b/src/creature.cpp index 5c3bb8e..dcc8337 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -14,7 +14,7 @@ Creature::Creature(Window m, std::string s) //Constructor void Creature::Behavior() { - health--; //Decrements health each time a behavior is executed + health-=5; //Decrements health each time a behavior is executed this->Priority(); //Checks which action has priority (doesn't really do this right now) this->Action(); //Does action } 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 } } diff --git a/src/resource.cpp b/src/resource.cpp index e549214..6a228fe 100644 --- a/src/resource.cpp +++ b/src/resource.cpp @@ -6,17 +6,15 @@ Resource::Resource(Window m, std::string s) //Constructor renderer = m.getRenderer(); //Initialized random position coordinates - int yStart = rand()%800; - int xStart = rand()%1200; - yPosition = yStart; - xPosition = xStart; + yPosition = rand()%800; + xPosition = rand()%1200; } Resource::Resource(Window m, std::string s, Location z) { texture = loadTexture(s, m); renderer = m.getRenderer(); - + yPosition = z.y; xPosition = z.x; } |