aboutsummaryrefslogtreecommitdiffstats
path: root/src/entities.cpp
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2015-10-08 09:09:15 -0400
committerdrumsetmonkey <abelleisle@roadrunner.com>2015-10-08 09:09:15 -0400
commitedf746b79c8646c2c21c04997d23c94c1ee8adcd (patch)
tree10479cd0a9868a4678af8acb5ebaf8f2c4d8dc7c /src/entities.cpp
parent281da1f81b1eef9e05e881e12d986b6b45ce8696 (diff)
Added mob class, and basic skirl
Diffstat (limited to 'src/entities.cpp')
-rw-r--r--src/entities.cpp67
1 files changed, 50 insertions, 17 deletions
diff --git a/src/entities.cpp b/src/entities.cpp
index 127adae..565c369 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -23,14 +23,13 @@ void Entity::spawn(float x, float y){ //spawns the entity you pass to it based o
void Entity::draw(void){ //draws the entities
glPushMatrix();
if(type==NPCT){
- if(gender == MALE){
- glColor3ub(255,255,255);
- }else if(gender == FEMALE){
- glColor3ub(255,105,180);
- }
if(NPCp(this)->aiFunc.size()){
glColor3ub(255,255,0);
glRectf(loc.x+width/3,loc.y+height,loc.x+width*2/3,loc.y+height+width/3);
+ }if(gender == MALE){
+ glColor3ub(255,255,255);
+ }else if(gender == FEMALE){
+ glColor3ub(255,105,180);
}
}else{
glColor3ub(255,255,255);
@@ -89,18 +88,6 @@ void Entity::draw(void){ //draws the entities
}
}
-void Entity::wander(int timeRun, vec2 *v){ //this makes the entites wander about
- static int direction; //variable to decide what direction the entity moves
- if(ticksToUse == 0){
- ticksToUse = timeRun;
- v->x = .008*HLINE; //sets the inital velocity of the entity
- direction = (getRand() % 3 - 1); //sets the direction to either -1, 0, 1
- //this lets the entity move left, right, or stay still
- v->x *= direction; //changes the velocity based off of the direction
- }
- ticksToUse--; //removes one off of the entities timer
-}
-
void Entity::getName(){
rewind(names);
char buf,*bufs = (char *)malloc(16);
@@ -167,6 +154,19 @@ NPC::NPC(){ //sets all of the NPC specific traits on object creation
inv = new Inventory(NPC_INV_SIZE);
}
+void NPC::wander(int timeRun, vec2 *v){ //this makes the entites wander about
+ static int direction; //variable to decide what direction the entity moves
+ if(ticksToUse == 0){
+ ticksToUse = timeRun;
+ v->x = .008*HLINE; //sets the inital velocity of the entity
+ direction = (getRand() % 3 - 1); //sets the direction to either -1, 0, 1
+ //this lets the entity move left, right, or stay still
+ v->x *= direction; //changes the velocity based off of the direction
+ }
+ ticksToUse--; //removes one off of the entities timer
+}
+
+
void NPC::addAIFunc(int (*func)(NPC *)){
aiFunc.push_back(func);
}
@@ -215,3 +215,36 @@ unsigned int Structures::spawn(_TYPE t, float x, float y){ //spawns a structure
return entity.size();
}
}
+Mob::Mob(){
+ width = HLINE * 10;
+ height = HLINE * 8;
+ speed = 1;
+ type = MOBT; //sets type to MOB
+ subtype = 1; //SKIRL
+ alive = true;
+ canMove = true;
+ near = false;
+ texture[0] = loadTexture("assets/NPC.png");
+ texture[1] = 0;
+ texture[2] = 0;
+ inv = new Inventory(NPC_INV_SIZE);
+}
+
+void Mob::wander(int timeRun, vec2* v){
+ if(subtype == 1){ //SKIRL
+ static int direction; //variable to decide what direction the entity moves
+ if(ticksToUse == 0){
+ ticksToUse = timeRun;
+ if(ground && direction != 0){
+ v->y=.08;
+ loc.y+=HLINE*1;
+ ground=false;
+ v->x = .008*HLINE; //sets the inital velocity of the entity
+ }
+ direction = (getRand() % 3 - 1); //sets the direction to either -1, 0, 1
+ //this lets the entity move left, right, or stay still
+ v->x *= direction; //changes the velocity based off of the direction
+ }
+ ticksToUse--; //removes one off of the entities timer
+ }
+} \ No newline at end of file