]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
Fixed entities
authordrumsetmonkey <abelleisle@roadrunner.com>
Mon, 28 Sep 2015 12:13:09 +0000 (08:13 -0400)
committerdrumsetmonkey <abelleisle@roadrunner.com>
Mon, 28 Sep 2015 12:13:09 +0000 (08:13 -0400)
src/entities.cpp
src/main.cpp

index da28851676e7085ea2a3c9dca4595d9355fbc5f6..d31f4278f7b6da1b0cdd1304172ce9e10b720e60 100644 (file)
@@ -50,9 +50,9 @@ NPC::NPC(){
        width = HLINE * 8;
        height = HLINE * 12;
        speed = 1;
-       type = 0;
+       type = 1;
        subtype = 0;
-       alive = false;
+       alive = true;
        canMove = true;
 }
 
@@ -78,14 +78,15 @@ unsigned int Structures::spawn(int t, float x, float y){
                //int tempN = (getRand() % 5 + 1);
                int tempN = 2;
                for(int i=0;i<tempN;i++){
-                       entity.push_back(new Entity());
+                       entity.push_back(new NPC());
                        npc.push_back(NPC());
                        std::cout<<"NPC:"<<npc.size()<<std::endl;
                        std::cout<<"Entity:"<<entity.size()<<std::endl;
                        entity[entity.size()] = &npc[npc.size()-1];
-                       entity[entity.size()]->alive=true;
-                       entity[entity.size()]->type = 1;
-                       entity[entity.size()]->spawn(loc.x + (float)(i - 5) / 8,100);
+                       entity[entity.size()-1]->spawn(loc.x + (float)(i - 5) / 8,100);
+                       std::cout<<"Entity Type["<<entity.size()<<"]: "<<entity[entity.size()]->type<<std::endl;
+                       std::cout<<"Entity Life["<<entity.size()<<"]: "<<entity[entity.size()]->alive<<std::endl;
+
                }
                return entity.size();
        }
index 0ba715fa98d031224c2a259c818d5bb9f79dc6ba..dae4189015e782e4eafd5e43462faf41eb0c5de3 100644 (file)
@@ -198,6 +198,7 @@ void logic(){
        for(int i=0;i<=entity.size();i++){
                if(entity[i]->alive&&entity[i]->type == 1){
                        entity[i]->wander(90, &entity[i]->vel);
+                       std::cout<<"works"<<i<<std::endl;
                }
        }
 }