summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authormajortom6 <tombarrett@siu.edu>2017-02-26 11:14:31 -0600
committerTom Barrett <tombarrett@siu.edu>2017-03-07 13:23:42 -0600
commit7394b069537ed7a490a343381d62862eb22abdcf (patch)
treec8bff4f88cf962ec4148a2e133bf959035feedb7 /inc
parente54170cfb8c0fb99ecdc3b1e57e832dec58ee76e (diff)
-REMOVED ENTITY, RESOURCE, AND CREATURE !
-replaced them all with one class, organism (always subject to change) -the dna type now is what differs creatures and resources -removed dead constants -may be a rogue segfault -also weird artifacts start showing if running long
Diffstat (limited to 'inc')
-rw-r--r--inc/constants.hpp17
-rw-r--r--inc/creature.hpp51
-rw-r--r--inc/dna.hpp11
-rw-r--r--inc/entity.hpp32
-rw-r--r--inc/list.hpp15
-rw-r--r--inc/opengl/spritebatch.hpp6
-rw-r--r--inc/organism.hpp63
-rw-r--r--inc/quadtree.hpp10
-rw-r--r--inc/resource.hpp24
9 files changed, 90 insertions, 139 deletions
diff --git a/inc/constants.hpp b/inc/constants.hpp
index dc0ddec..ce4c3ff 100644
--- a/inc/constants.hpp
+++ b/inc/constants.hpp
@@ -14,28 +14,23 @@ const int RESOURCE_TYPE = 2;
// Creatures
const int CREATURE_MAX_HEALTH = 1000;
-const int CREATURE_REACH = 1;
-const int CREATURE_BEST_SENSE = 1;
+const int CREATURE_BEST_SENSE = 2;
const int CREATURE_BITE = 10;
-const int CREATURE_AMOUNT_TO_GROW = 50;
const int CREATURE_EXP_PREG_TIME = 100;
-const int CREATURE_EXP_AGE = 1000000;
-const int CREATURE_SIZE_MAX = 10;
+const int CREATURE_EXP_AGE = 1000;
const float CREATURE_SPEED = .1;
const float CREATURE_MUTATION_PERCENT = .25;
const float CREATURE_MUTATION_CHANCE = .05;
+const float CREATURE_REACH = .1;
// Resource
-const int RESOURCE_SIZE_START = 1;
-const int RESOURCE_SIZE_MAX = 4;
-const int RESOURCE_AMOUNT_START = 100;
-const int RESOURCE_AMOUNT_MAX = 200;
-const int RESOURCE_GROW = 1;
+const int RESOURCE_MAX_HEALTH = 200;
+const int RESOURCE_GROW_AMOUNT = 1;
// Opengl
const int NUM_SHADERS = 3;
const int NUM_UNIFORMS = 3;
-const float CREATURE_SIDES = 4.0;
+const float CREATURE_SIDES = 4;
const float RESOURCE_SIDES = 10;
// Quadtree
diff --git a/inc/creature.hpp b/inc/creature.hpp
deleted file mode 100644
index 8174cf6..0000000
--- a/inc/creature.hpp
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef creature_h
-#define creature_h
-
-#include <vector>
-#include <algorithm>
-
-#include "entity.hpp"
-#include "functions.hpp"
-
-class Creature: public Entity
-{
- public:
- Creature(Rectangle r, DNA d);
-
- void Behavior();
- void Action();
- void Priority();
- void setTarget();
- void checkTarget();
- void moveTowards(Rectangle r);
- void impregnate(DNA d);
- void giveNearMe(std::vector<Entity*> n){nearMe = n;};
-
- DNA getDNA(){return myDNA;};
- DNA getChildsDNA(){return childsDNA;};
- int getHealth(){return health;};
- int getBestSense(){return myDNA.bestSense;};
- bool getGender(){return gender;};
- bool getPregnancyReady(){return pregnancyReady;};
- void hadPregnancy(){pregnate = pregnancyReady = false;};
-
- private:
- Rectangle wTarget;
- Entity* target;
- std::vector<Entity*> nearMe;
- DNA myDNA;
- DNA childsDNA;
-
- int health;
- int amountAte;
- int pregnancyTime;
- int age;
-
- bool hungry;
- bool pregnancyReady;
- bool able;
- bool hasTarget;
- bool wander;
-};
-
-#endif
diff --git a/inc/dna.hpp b/inc/dna.hpp
index b549c27..8c4effa 100644
--- a/inc/dna.hpp
+++ b/inc/dna.hpp
@@ -1,25 +1,28 @@
#ifndef dna_h
#define dna_h
+#include <string>
+
#include "constants.hpp"
#include "functions.hpp"
class DNA
{
public:
- DNA();
+ DNA(){};
+ DNA(std::string s);
DNA combine(DNA D);
+ int type;
int maxHealth;
- int reach;
int bestSense;
int bite;
- int amountToGrow;
int expectedPregnancyTime;
int expectedAge;
- int sizeMax;
+ int growAmount;
+ float reach;
float speed;
float mutationPercent;
float mutationChance;
diff --git a/inc/entity.hpp b/inc/entity.hpp
deleted file mode 100644
index 20c87aa..0000000
--- a/inc/entity.hpp
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef entity_h
-#define entity_h
-
-#include "dna.hpp"
-#include "rectangle.hpp"
-
-#include "opengl/graphicsdata.hpp"
-
-class Entity
-{
- public:
- void Place();
-
- virtual void eat(int bite){};
- virtual void impregnate(DNA D){};
-
- int getType(){return type;};
- virtual bool getGender(void){};
- virtual int getAmount(void){};
- Rectangle getRectangle(){return rect;};
- GraphicsData getGFXD(){return gfxData;};
-
-
- protected:
- int type;
- int gender;
- bool pregnate;
- Rectangle rect;
- GraphicsData gfxData;
-};
-
-#endif
diff --git a/inc/list.hpp b/inc/list.hpp
index f62112c..93a0537 100644
--- a/inc/list.hpp
+++ b/inc/list.hpp
@@ -5,22 +5,21 @@
#include <vector>
#include "constants.hpp"
-#include "creature.hpp"
-#include "resource.hpp"
+#include "organism.hpp"
#include "quadtree.hpp"
class List
{
public:
List();
- void Behavior();
- void Place();
- void Remove();
+ void Behavior();
+ void Place();
+ void Remove();
- std::vector<Entity*> getNear(Creature c);
+ std::vector<Organism*> getNear(Organism o);
- std::list<Resource> resources;
- std::list<Creature> creatures;
+ std::list<Organism> resources;
+ std::list<Organism> creatures;
Quadtree tree;
std::vector<GraphicsData> drawQuadTree();
diff --git a/inc/opengl/spritebatch.hpp b/inc/opengl/spritebatch.hpp
index 2618054..63e45eb 100644
--- a/inc/opengl/spritebatch.hpp
+++ b/inc/opengl/spritebatch.hpp
@@ -1,12 +1,12 @@
#ifndef spritebatch_h
#define spritebatch_h
+#include <iostream>
+#include <vector>
#include <GL/glew.h>
+
#include "graphicsdata.hpp"
-#include <vector>
#include "geoshader.hpp"
-#include <iostream>
-
class RenderBatch {
public:
diff --git a/inc/organism.hpp b/inc/organism.hpp
new file mode 100644
index 0000000..9534fbb
--- /dev/null
+++ b/inc/organism.hpp
@@ -0,0 +1,63 @@
+#ifndef organism_h
+#define organism_h
+
+#include <vector>
+#include <algorithm>
+
+#include "dna.hpp"
+#include "rectangle.hpp"
+#include "functions.hpp"
+
+#include "opengl/graphicsdata.hpp"
+
+class Organism
+{
+ public:
+ Organism(Rectangle r, DNA d);
+
+ void Behavior();
+ void Action();
+ void Priority();
+ void Place();
+ void setTarget();
+ void checkTarget();
+ void moveTowards(Rectangle r);
+ void passDNA(DNA d);
+ void giveNearMe(std::vector<Organism*> n){nearMe = n;};
+ void grow();
+ void takeBite(int bite);
+ void hadPregnancy(){pregnate = pregnancyReady = false;};
+
+ DNA getDNA() {return myDNA;};
+ DNA getChildsDNA() {return childsDNA;};
+ GraphicsData getGFXD() {return gfxData;};
+ Rectangle getRectangle() {return rect;};
+ int getHealth() {return health;};
+ int getBestSense() {return myDNA.bestSense;};
+ int getType() {return myDNA.type;};
+ bool getGender() {return gender;};
+ bool getPregnancyReady() {return pregnancyReady;};
+
+ private:
+ Rectangle wTarget;
+ Organism* target;
+ std::vector<Organism*> nearMe;
+ DNA myDNA;
+ DNA childsDNA;
+ Rectangle rect;
+ GraphicsData gfxData;
+
+ int health;
+ int pregnancyTime;
+ int age;
+
+ bool gender;
+ bool pregnate;
+ bool hungry;
+ bool pregnancyReady;
+ bool able;
+ bool hasTarget;
+ bool wander;
+};
+
+#endif
diff --git a/inc/quadtree.hpp b/inc/quadtree.hpp
index bf308f8..8520584 100644
--- a/inc/quadtree.hpp
+++ b/inc/quadtree.hpp
@@ -4,9 +4,7 @@
#include <vector>
#include "constants.hpp"
-#include "creature.hpp"
-#include "resource.hpp"
-#include "entity.hpp"
+#include "organism.hpp"
#include "rectangle.hpp"
#include "opengl/graphicsdata.hpp"
@@ -18,10 +16,10 @@ class Quadtree {
Quadtree(int pLevel,Rectangle pBounds);
void clear();
- void insert(Entity* iter);
+ void insert(Organism* iter);
- std::vector<Entity*> retrieve(std::vector<Entity*> returnObject, GraphicsData obj);
- std::vector<Entity*> objects;
+ std::vector<Organism*> retrieve(std::vector<Organism*> returnObject, GraphicsData obj);
+ std::vector<Organism*> objects;
Quadtree* nodes;
diff --git a/inc/resource.hpp b/inc/resource.hpp
deleted file mode 100644
index e559463..0000000
--- a/inc/resource.hpp
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef resource_h
-#define resource_h
-
-#include <cstdlib>
-
-#include "entity.hpp"
-#include "functions.hpp"
-
-class Resource: public Entity
-{
- public:
- Resource(Rectangle r);
-
- void grow();
- void eat(int bite);
-
- int getAmount(){return amount;};
-
- private:
- int amount;
- int growAmount;
-};
-
-#endif