From aaf0a73578ecbb8212e0d224d6fff68a229b1f48 Mon Sep 17 00:00:00 2001 From: tom Date: Tue, 5 May 2015 21:01:52 -0500 Subject: fleshed out list, locations of all creatures and resources are now within --- inc/creature.hpp | 9 +++++++-- inc/list.hpp | 3 ++- inc/location.hpp | 17 +++++++++++++++++ inc/main.hpp | 1 + inc/resource.hpp | 5 +++++ inc/window.hpp | 1 + src/creature.cpp | 30 +++++++++++++++++++++--------- src/event.cpp | 10 +++++----- src/list.cpp | 27 ++++++++++++++++++++------- src/main.cpp | 4 ++-- src/resource.cpp | 12 ++++++++++-- src/window.cpp | 10 +++++----- 12 files changed, 96 insertions(+), 33 deletions(-) create mode 100644 inc/location.hpp diff --git a/inc/creature.hpp b/inc/creature.hpp index ab4b328..f72dfbc 100644 --- a/inc/creature.hpp +++ b/inc/creature.hpp @@ -2,17 +2,22 @@ #define creature_h #include "entity.hpp" +#include "location.hpp" class Creature: public Entity { public: Creature(Window m, std::string s); void Behavior(); - void Action(); - + void Action(); + Location getLocation(); + private: int xT; int yT; + int hp; + int hu; + Location K[3]; }; #endif diff --git a/inc/list.hpp b/inc/list.hpp index 240fa95..203ad7f 100644 --- a/inc/list.hpp +++ b/inc/list.hpp @@ -4,6 +4,7 @@ #include "creature.hpp" #include "resource.hpp" #include "window.hpp" +#include "location.hpp" class List { @@ -16,7 +17,7 @@ class List //Window main; std::vector R; std::vector C; - int ** L; + std::vector L; }; #endif diff --git a/inc/location.hpp b/inc/location.hpp new file mode 100644 index 0000000..c4428f5 --- /dev/null +++ b/inc/location.hpp @@ -0,0 +1,17 @@ +#ifndef location_h +#define location_h + +class Location +{ + public: + Location(){x=y=t=0;}; + Location(int x, int y, int z){}; + int getType(){return t;}; + + private: + int x; + int y; + int t; +}; + +#endif diff --git a/inc/main.hpp b/inc/main.hpp index 4360cf9..c6f51e3 100644 --- a/inc/main.hpp +++ b/inc/main.hpp @@ -7,5 +7,6 @@ #include "creature.hpp" #include "resource.hpp" #include "list.hpp" +#include "location.hpp" #endif diff --git a/inc/resource.hpp b/inc/resource.hpp index 986a03d..2738f44 100644 --- a/inc/resource.hpp +++ b/inc/resource.hpp @@ -2,11 +2,16 @@ #define resource_h #include "entity.hpp" +#include "location.hpp" class Resource: public Entity { public: Resource(Window m, std::string s); + Location getLocation(); + + private: + int amount; }; #endif diff --git a/inc/window.hpp b/inc/window.hpp index 2f65b04..d3436d8 100644 --- a/inc/window.hpp +++ b/inc/window.hpp @@ -1,6 +1,7 @@ #ifndef window_h #define window_h +//Theres alot here that are probs not used needs cleaning #include #include #include diff --git a/src/creature.cpp b/src/creature.cpp index 8e86c0d..cc3fa08 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -4,23 +4,25 @@ Creature::Creature(Window m, std::string s) { texture = loadTexture(s, m); renderer = m.getRenderer(); + hp = 100; + hu = 0; - srand(time(NULL)); - int z = rand()%800; - y=z; - - z = rand()%800; - x=z; - std::cout << x << ' ' << y << std::endl; - + int zy = rand()%800; + int zx = rand()%1200; + y=zy; + x=zx; + //std::cout << x << ' ' << y << std::endl; + //For the test resource xT=yT=300; } void Creature::Behavior() { + hp--; //Detection + //Priorities //Action @@ -34,15 +36,19 @@ void Creature::Action() return; //eat//reproduce//etc; if(x==xT) + { if(y