summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortom <tom@ground-control>2016-05-02 16:08:20 -0500
committertom <tom@ground-control>2016-05-02 16:08:20 -0500
commit42d7b3bb511333e242a74f360873deb64cd89522 (patch)
treefdc15da04b62c7a865933aaea49996e719f60ac7
parent2b17703707dab3af620fe05a73f05fc6f856e0b1 (diff)
spring cleaning
-rw-r--r--inc/creature.hpp21
-rw-r--r--inc/entity.hpp4
-rw-r--r--inc/list.hpp4
-rw-r--r--inc/location.hpp12
-rw-r--r--inc/resource.hpp2
-rw-r--r--inc/window.hpp4
-rw-r--r--src/creature.cpp9
7 files changed, 24 insertions, 32 deletions
diff --git a/inc/creature.hpp b/inc/creature.hpp
index 64efd26..875b498 100644
--- a/inc/creature.hpp
+++ b/inc/creature.hpp
@@ -15,28 +15,29 @@ class Creature: public Entity
Location getLocation();
void giveR(vector<Resource*> n){nR=n;};
void giveC(vector<Creature*> n){nC=n;};
+
+ double Distance(Location A, Location B){return sqrt(pow(A.x-B.x,2)+pow(A.y-B.y,2));};
int getHealth(){return health;};
- double Distance(Location A, Location B);
- bool doesItHaveTarget();
+ bool doesItHaveTarget(){return hasTarget;};
int getBestSense(){return bestSense;};
private:
- int xTarget; //x-coordinate of creature's target position
- int yTarget; //y-coordinate of creature's target position
+ int xTarget;
+ int yTarget;
bool hasTarget;
bool wandering;
- int health; //health of a creature (0-100)
+ int health;
int maxHealth;
- int hunger; //value associated with a creatures want to find food (0-100)
- int speed = 1;
- bool able; // ability to reproduce
- int bestSense = 100; // Distance it can see/smell/hear
+ int hunger;
+ int speed = 2;
+ bool able;
+ int bestSense = 100;
vector<Resource*> nR; //vector containing resources near the creature
vector<Creature*> nC; //vector containing creatures near the creature
- int n; // counter for which place in resource array is targeted
+ int n;
};
#endif
diff --git a/inc/entity.hpp b/inc/entity.hpp
index 079da9b..803c1e4 100644
--- a/inc/entity.hpp
+++ b/inc/entity.hpp
@@ -2,6 +2,7 @@
#define entity_h
#include "window.hpp"
+#include "location.hpp"
class Entity
{
@@ -10,8 +11,9 @@ class Entity
SDL_Texture* loadTexture(std::string path, Window main);
protected:
+ //Location L;
int xPosition, yPosition; //Coordinates of entity on window
- int height, width; //Dimensions of image on window
+ int height, width; //Dimensions of image on window
int degrees = 0;
SDL_Texture* texture;
SDL_Renderer* renderer;
diff --git a/inc/list.hpp b/inc/list.hpp
index 934c319..05e9fcc 100644
--- a/inc/list.hpp
+++ b/inc/list.hpp
@@ -17,8 +17,8 @@ class List
private:
//vectors containing objects of each type
Window main = Window("no");//will be needed for adding R's and C's after constructor.
- std::vector<Resource> R;
- std::vector<Creature> C;
+ vector<Resource> R;
+ vector<Creature> C;
};
#endif
diff --git a/inc/location.hpp b/inc/location.hpp
index e45642d..9f50863 100644
--- a/inc/location.hpp
+++ b/inc/location.hpp
@@ -3,13 +3,11 @@
class Location
{
- public:
- Location(){x=y=type=0;}; //is this line needed?
- Location(int x1, int y1, int t1){x=x1;y=y1;type=t1;};
-
- int x; //x-coordinate of entity
- int y; //y-coordinate of entity
- int type; //value associated with type of entity at location. 1: Creature, 2: Resource
+ public:
+ Location(int x1, int y1, int t1){x=x1;y=y1;type=t1;};
+ int x; //x-coordinate of entity
+ int y; //y-coordinate of entity
+ int type; //value associated with type of entity at location. 1: Creature, 2: Resource
};
#endif
diff --git a/inc/resource.hpp b/inc/resource.hpp
index c551844..5c45f96 100644
--- a/inc/resource.hpp
+++ b/inc/resource.hpp
@@ -14,7 +14,7 @@ class Resource: public Entity
int getAmount(){return amount;};
private:
- int amount; //value associated with the amount of whatever (food, etc) left in the resource
+ int amount;
};
#endif
diff --git a/inc/window.hpp b/inc/window.hpp
index 1ea2733..b9f9175 100644
--- a/inc/window.hpp
+++ b/inc/window.hpp
@@ -1,7 +1,7 @@
#ifndef window_h
#define window_h
-//Theres alot here that are probs not used needs cleaning
+//Theres alot here that are probs not used, needs cleaning
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <string>
@@ -19,7 +19,7 @@ class Window
{
public:
Window();
- Window(std::string){};
+ Window(string){};
void Destroy();
void Clear();
diff --git a/src/creature.cpp b/src/creature.cpp
index 10274b6..83b9f4d 100644
--- a/src/creature.cpp
+++ b/src/creature.cpp
@@ -164,13 +164,4 @@ Location Creature::getLocation()
return L;
}
-double Creature::Distance(Location A, Location B)
-{
- //computes distance between two points
- return sqrt(pow(A.x - B.x, 2) + pow(A.y - B.y, 2));
-}
-bool Creature::doesItHaveTarget()
-{
- return hasTarget;
-}