From 7d974f6f4d54b3fbea99780ddf6e395b217065bc Mon Sep 17 00:00:00 2001
From: Andy Belle-Isle <abelleisle@roadrunner.com>
Date: Mon, 14 Sep 2015 11:51:05 -0400
Subject: Added NPC Stuff

Added Wandering, and variable spawning amounts
---
 src/entities.cpp | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

(limited to 'src/entities.cpp')

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
-- 
cgit v1.2.3