summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/list.cpp14
-rw-r--r--src/resource.cpp9
2 files changed, 20 insertions, 3 deletions
diff --git a/src/list.cpp b/src/list.cpp
index 2140a75..e5ac9b8 100644
--- a/src/list.cpp
+++ b/src/list.cpp
@@ -17,6 +17,8 @@ List::List(Window m) //Constructor
R.push_back(Y);
L.push_back(Y.getLocation());
}
+
+ main = &m;
}
void List::Place()
@@ -47,15 +49,21 @@ void List::Behavior()
int i, j;
std::vector<Location> Z;
- //
for(i = 0; i < C.size(); i++)
{
C[i].Behavior(); //executes the behavior of the creature at i
+
+ // This kills the creature
+ if(C[i].getHealth()==0)
+ {
+ Location z = C[i].getLocation();
+ R.push_back(Resource(main,"img/Cdead.png",z));
+ 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 5044760..e549214 100644
--- a/src/resource.cpp
+++ b/src/resource.cpp
@@ -12,6 +12,15 @@ Resource::Resource(Window m, std::string s) //Constructor
xPosition = xStart;
}
+Resource::Resource(Window m, std::string s, Location z)
+{
+ texture = loadTexture(s, m);
+ renderer = m.getRenderer();
+
+ yPosition = z.y;
+ xPosition = z.x;
+}
+
Location Resource::getLocation() //Returns resource object
{
Location L(xPosition,yPosition,2);