diff options
author | Andy Belle-Isle <abelleisle@roadrunner.com> | 2015-09-14 11:51:05 -0400 |
---|---|---|
committer | Andy Belle-Isle <abelleisle@roadrunner.com> | 2015-09-14 11:51:05 -0400 |
commit | 7d974f6f4d54b3fbea99780ddf6e395b217065bc (patch) | |
tree | b9d8fe2166eedc57137737091c08cd7bbd749ddf /src/entities.cpp | |
parent | d2d334f2cd3cc78f088f429eb5d0037268366e6d (diff) |
Added NPC Stuff
Added Wandering, and variable spawning amounts
Diffstat (limited to 'src/entities.cpp')
-rw-r--r-- | src/entities.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/entities.cpp b/src/entities.cpp index 849bd7c..e9e69ce 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -7,6 +7,8 @@ void Entity::spawn(float x, float y){ vel.y = 0; right = false; left = false; + ticksToUse = 0; + canMove = false; } void Entity::draw(void){ @@ -14,20 +16,33 @@ void Entity::draw(void){ glRectf(loc.x,loc.y,loc.x+width,loc.y+height); } +void Entity::wander(int timeRun, vec2 *v){ + if(ticksToUse == 0){ + ticksToUse = timeRun; + v->x = .00010; + int hey = (grand() % 3 - 1); + v->x *= hey; + } + ticksToUse--; +} + Player::Player(){ width = HLINE * 8; height = HLINE * 18; speed = 1; type = 0; subtype = 5; + alive = true; } -NPC::NPC(){ +NPC::NPC(){ width = HLINE * 8; height = HLINE * 18; speed = 1; type = 0; subtype = 0; + alive = false; + canMove = true; } Structures::Structures(){ @@ -45,7 +60,11 @@ void Structures::spawn(int t, float x, float y){ width = 4 * HLINE; height = 4 * HLINE; - for(int i = 0;i<10;i++){ + int tempN = (grand() % 5 + 1); + npcAmt = tempN; + + for(int i = 0;i<eAmt(entnpc);i++){ + npc[i].alive = true; entnpc[i] = &npc[i]; npc[i].type = -1; //this will make the NPC spawn the start of a village entnpc[i]->spawn(loc.x + (float)(i - 5) / 8,0); //this will spawn the start of a village |