summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authormajortom6 <tombarrett@siu.edu>2017-03-03 15:18:22 -0600
committerTom Barrett <tombarrett@siu.edu>2017-03-07 13:23:42 -0600
commitdfda3f2a5e555d3173359134f4994bcd12d129f8 (patch)
treeadc9d75f1e28332b8c5208fdb3c4685667816dda /inc
parent3c78d411760beb9332e7282e4ec49a199998c67d (diff)
-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)
Diffstat (limited to 'inc')
-rw-r--r--inc/constants.hpp2
-rw-r--r--inc/dna.hpp7
-rw-r--r--inc/list.hpp2
-rw-r--r--inc/opengl/graphicsdata.hpp33
-rw-r--r--inc/opengl/spritebatch.hpp10
-rw-r--r--inc/organism.hpp6
-rw-r--r--inc/quadtree.hpp11
7 files changed, 20 insertions, 51 deletions
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<Organism> creatures;
Quadtree tree;
- std::vector<GraphicsData> drawQuadTree();
+ std::vector<Rectangle> 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 <vector>
#include <GL/glew.h>
-#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<GraphicsData*> _gfxPtr;
- std::vector<GraphicsData> _gfx;
- std::vector<RenderBatch> _renderBatches;
+ std::vector<std::pair<Rectangle,DNA::Visuals>*> _gfxPtr;
+ std::vector<std::pair<Rectangle,DNA::Visuals>> _gfx;
+ std::vector<RenderBatch> _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<Organism*> retrieve(std::vector<Organism*> returnObject, GraphicsData obj);
+ std::vector<Organism*> retrieve(std::vector<Organism*> returnObject, Rectangle obj);
std::vector<Organism*> objects;
Quadtree* nodes;
- std::vector<GraphicsData> Draw();
+ std::vector<Rectangle> Draw();
private:
void split();
- int getIndex(GraphicsData object);
+ int getIndex(Rectangle object);
int level;
bool isNull = true;
- GraphicsData gfxDataRect;
+ Rectangle rect;
Rectangle bounds;
};