From c63d77ddddb69ef0f641d90a8c3922fdc356224c Mon Sep 17 00:00:00 2001 From: dakjos Date: Thu, 7 May 2015 19:53:39 -0500 Subject: Some variable names changed and many comments made so I understand what the fuck is going on --- src/creature.cpp | 131 ++++++++++++++++++++++++------------------------------- 1 file changed, 56 insertions(+), 75 deletions(-) (limited to 'src/creature.cpp') diff --git a/src/creature.cpp b/src/creature.cpp index ae3122b..ef3d6c1 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -1,119 +1,100 @@ #include "creature.hpp" -Creature::Creature(Window m, std::string s) +Creature::Creature(Window m, std::string s) //Constructor { texture = loadTexture(s, m); renderer = m.getRenderer(); - hp = 100; - hu = 0; + health = 100; + hunger = 0; - int zy = rand()%800; - int zx = rand()%1200; - y=yT=zy; - x=xT=zx; - //std::cout << x << ' ' << y << std::endl; - - //For the test resource - //xT=yT=300; + //initializes random start coordinates for creature, target position is equivalent to it's position + int yStart = rand()%800; + int xStart = rand()%1200; + yPosition=yTarget=yStart; + xPosition=xTarget=xStart; } void Creature::Behavior() { - hp--; + health--; //Decrements health each time a behavior is executed //Detection + this->Priority(); //Checks which action has priority (doesn't really do this right now) + this->Action(); //Does action +} - //Priorities - this->Priority(); - //Action - this->Action(); +void Creature::Priority() +{ + //Traverses location vector, if object at [i] is resource (2), then creature's target coordinates are set + int i; + for(i=0;ixT) + + else if(xPositionxTarget) { - int z = rand()%2; - if(z) - { - if(x