From dfda3f2a5e555d3173359134f4994bcd12d129f8 Mon Sep 17 00:00:00 2001 From: majortom6 Date: Fri, 3 Mar 2017 15:18:22 -0600 Subject: -removed the Graphics Data class -replaced with already implemented Rectangle, and put color and side variables in dna (can potentially remove the side variable if it does nothing important) --- inc/constants.hpp | 2 +- inc/dna.hpp | 7 +++++++ inc/list.hpp | 2 +- inc/opengl/graphicsdata.hpp | 33 --------------------------------- inc/opengl/spritebatch.hpp | 10 +++++----- inc/organism.hpp | 6 +----- inc/quadtree.hpp | 11 +++++------ 7 files changed, 20 insertions(+), 51 deletions(-) delete mode 100644 inc/opengl/graphicsdata.hpp (limited to 'inc') diff --git a/inc/constants.hpp b/inc/constants.hpp index 41fc082..e7d69b4 100644 --- a/inc/constants.hpp +++ b/inc/constants.hpp @@ -14,7 +14,7 @@ const int RESOURCE_TYPE = 2; // Creatures const int CREATURE_MAX_HEALTH = 1000; -const int CREATURE_BEST_SENSE = 2; +const int CREATURE_BEST_SENSE = 1.5; const int CREATURE_BITE = 10; const int CREATURE_EXP_PREG_TIME = 100; const int CREATURE_EXP_AGE = 10000; diff --git a/inc/dna.hpp b/inc/dna.hpp index 8c4effa..1126638 100644 --- a/inc/dna.hpp +++ b/inc/dna.hpp @@ -26,6 +26,13 @@ class DNA float speed; float mutationPercent; float mutationChance; + + struct Visuals{ + float sides; + float red; + float green; + float blue; + } appearance; }; #endif diff --git a/inc/list.hpp b/inc/list.hpp index 5f1ba8e..b5da34c 100644 --- a/inc/list.hpp +++ b/inc/list.hpp @@ -22,7 +22,7 @@ class List std::list creatures; Quadtree tree; - std::vector drawQuadTree(); + std::vector drawQuadTree(); }; #endif diff --git a/inc/opengl/graphicsdata.hpp b/inc/opengl/graphicsdata.hpp deleted file mode 100644 index a0398dc..0000000 --- a/inc/opengl/graphicsdata.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef graphicsdata_h -#define graphicsdata_h - -class GraphicsData -{ - public: - GraphicsData(){ - this->x = 0; - this->y = 0; - this->r = 0; - this->g = 0; - this->b = 0; - this->sides = 0; - } - - GraphicsData(float x1, float y1, float r1, float g1, float b1, float sides1){ - this->x = x1; - this->y = y1; - this->r = r1; - this->g = g1; - this->b = b1; - this->sides = sides1; - } - - float x; - float y; - float r; - float g; - float b; - float sides; -}; - -#endif diff --git a/inc/opengl/spritebatch.hpp b/inc/opengl/spritebatch.hpp index 63e45eb..d1c4d7a 100644 --- a/inc/opengl/spritebatch.hpp +++ b/inc/opengl/spritebatch.hpp @@ -5,8 +5,8 @@ #include #include -#include "graphicsdata.hpp" #include "geoshader.hpp" +#include "dna.hpp" class RenderBatch { public: @@ -24,7 +24,7 @@ class SpriteBatch void init(); void begin(); void end(); - void draw(const GraphicsData& gfxData); + void draw(Rectangle r, DNA::Visuals v); void renderBatch(); private: @@ -34,9 +34,9 @@ class SpriteBatch GLuint _vbo; GLuint _vao; - std::vector _gfxPtr; - std::vector _gfx; - std::vector _renderBatches; + std::vector*> _gfxPtr; + std::vector> _gfx; + std::vector _renderBatches; GeoShader shader; }; diff --git a/inc/organism.hpp b/inc/organism.hpp index 9534fbb..2a7a67c 100644 --- a/inc/organism.hpp +++ b/inc/organism.hpp @@ -8,8 +8,6 @@ #include "rectangle.hpp" #include "functions.hpp" -#include "opengl/graphicsdata.hpp" - class Organism { public: @@ -18,7 +16,6 @@ class Organism void Behavior(); void Action(); void Priority(); - void Place(); void setTarget(); void checkTarget(); void moveTowards(Rectangle r); @@ -30,7 +27,7 @@ class Organism DNA getDNA() {return myDNA;}; DNA getChildsDNA() {return childsDNA;}; - GraphicsData getGFXD() {return gfxData;}; + DNA::Visuals getVisuals() {return myDNA.appearance;}; Rectangle getRectangle() {return rect;}; int getHealth() {return health;}; int getBestSense() {return myDNA.bestSense;}; @@ -45,7 +42,6 @@ class Organism DNA myDNA; DNA childsDNA; Rectangle rect; - GraphicsData gfxData; int health; int pregnancyTime; diff --git a/inc/quadtree.hpp b/inc/quadtree.hpp index 8520584..eb50db8 100644 --- a/inc/quadtree.hpp +++ b/inc/quadtree.hpp @@ -7,31 +7,30 @@ #include "organism.hpp" #include "rectangle.hpp" -#include "opengl/graphicsdata.hpp" #include "sdl/window.hpp" class Quadtree { public: Quadtree(); - Quadtree(int pLevel,Rectangle pBounds); + Quadtree(int pLevel, Rectangle pBounds); void clear(); void insert(Organism* iter); - std::vector retrieve(std::vector returnObject, GraphicsData obj); + std::vector retrieve(std::vector returnObject, Rectangle obj); std::vector objects; Quadtree* nodes; - std::vector Draw(); + std::vector Draw(); private: void split(); - int getIndex(GraphicsData object); + int getIndex(Rectangle object); int level; bool isNull = true; - GraphicsData gfxDataRect; + Rectangle rect; Rectangle bounds; }; -- cgit v1.2.3