diff options
author | Tom Barrett <tombarrett@cornell.engr.siu.edu> | 2015-05-01 14:02:12 -0500 |
---|---|---|
committer | Tom Barrett <tombarrett@cornell.engr.siu.edu> | 2015-05-01 14:02:12 -0500 |
commit | 386279f378d49f6dddb276fbfde92fe1444b6ea1 (patch) | |
tree | 90beed57e495ac409cec72b5bf42e3d6fb702e68 | |
parent | 7cbc9334a09540627df8845bb9952196276ae6f9 (diff) |
needs cleaning, hasnt been tested
-rw-r--r-- | inc/creature.h | 5 | ||||
-rw-r--r-- | inc/creature.h~ | 16 | ||||
-rw-r--r-- | inc/window.h | 2 | ||||
-rw-r--r-- | inc/window.h~ | 24 | ||||
-rw-r--r-- | src/creature.cpp | 40 | ||||
-rw-r--r-- | src/creature.cpp~ | 47 | ||||
-rw-r--r-- | src/resource.cpp~ | 8 |
7 files changed, 142 insertions, 0 deletions
diff --git a/inc/creature.h b/inc/creature.h index 5f5bb8d..eef0d03 100644 --- a/inc/creature.h +++ b/inc/creature.h @@ -7,6 +7,11 @@ class Creature: public Entity { public: Creature(Window m, std::string s); + void Behavior(); + void Action(); + private: + int xT; + int yT; }; #endif diff --git a/inc/creature.h~ b/inc/creature.h~ new file mode 100644 index 0000000..19d4cb3 --- /dev/null +++ b/inc/creature.h~ @@ -0,0 +1,16 @@ +#ifndef creature_h +#define creature_h + +#include "entity.h" + +class Creature: public Entity +{ + public: + Creature(Window m, std::string s); + void Behavior(); + private: + int xT; + int yT; +}; + +#endif diff --git a/inc/window.h b/inc/window.h index fb1cf67..17ba597 100644 --- a/inc/window.h +++ b/inc/window.h @@ -5,6 +5,8 @@ #include <SDL2/SDL_image.h> #include <string> #include <cmath> +#include <stdlib.h> +#include <time.h> class Window { diff --git a/inc/window.h~ b/inc/window.h~ new file mode 100644 index 0000000..fb1cf67 --- /dev/null +++ b/inc/window.h~ @@ -0,0 +1,24 @@ +#ifndef window_h +#define window_h + +#include <SDL2/SDL.h> +#include <SDL2/SDL_image.h> +#include <string> +#include <cmath> + +class Window +{ + public: + Window(); + void Destroy(); + + void Clear(); + void Render(); + SDL_Renderer* getRenderer(); + + private: + SDL_Window* main; + SDL_Renderer* renderer; +}; + +#endif diff --git a/src/creature.cpp b/src/creature.cpp index c96785e..437837d 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -5,4 +5,44 @@ Creature::Creature(Window m, std::string s) texture = loadTexture(s, m); renderer = m.getRenderer(); x=y=500; + + //For the test resource + xT=yT=300; +} + +void Creature::Behavior() +{ + //Detection + + //Priorities + + //Action + this->Action(); +} + +void Creature::Action() +{ + //if(isclose) + // eat//reproduce//etc; + + if(x==xT) + { + if(y<yT) + y++; + else + y--; + } + else if(y==yT) + { + if(x<xT) + x++; + else + x--; + } + else + { + srand(time(NULL)); + z = rand%1; + if( + } } diff --git a/src/creature.cpp~ b/src/creature.cpp~ new file mode 100644 index 0000000..15b6577 --- /dev/null +++ b/src/creature.cpp~ @@ -0,0 +1,47 @@ +#include "creature.h" + +Creature::Creature(Window m, std::string s) +{ + texture = loadTexture(s, m); + renderer = m.getRenderer(); + x=y=500; + + //For the test resource + xT=yT=300; +} + +void Creature::Behavior() +{ + //Detection + + //Priorities + + //Action + this->Action(); +} + +void Creature::Action() +{ + //if(isclose) + // eat//reproduce//etc; + + if(x==xT) + { + if(y<yT) + y++; + else + y--; + } + else if(y==yT) + { + if(x<xT) + x++; + else + x--; + } + else + { + + + } +} diff --git a/src/resource.cpp~ b/src/resource.cpp~ new file mode 100644 index 0000000..06c7a04 --- /dev/null +++ b/src/resource.cpp~ @@ -0,0 +1,8 @@ +#include "resource.h" + +Resource::Resource(Window m, std::string s) +{ + texture = loadTexture(s, m); + renderer = m.getRenderer(); + x=y=300; +} |