]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
screw npcs
authorClyne Sullivan <tullivan99@gmail.com>
Thu, 22 Oct 2015 13:27:55 +0000 (09:27 -0400)
committerClyne Sullivan <tullivan99@gmail.com>
Thu, 22 Oct 2015 13:27:55 +0000 (09:27 -0400)
1  2 
include/entities.h
main.cpp
src/entities.cpp

Simple merge
diff --cc main.cpp
Simple merge
index ce983e89d81862a55179431dd35eb4e1a6dde9ba,092ab7b945ead41d832a5a361ad10c2294294d80..7a4da65f3dfb62e888a6791e0d360fb8f9c6d9d7
@@@ -33,10 -33,14 +33,11 @@@ Player::Player(){ //sets all of the pla
        subtype = 0;
        maxHealth = 100;
        health = maxHealth;
-       texture[0] = loadTexture("assets/player.png");
-       texture[1] = loadTexture("assets/player1.png");
-       texture[2] = loadTexture("assets/player2.png");
+       alive = true;
+       ground = false;
+       near = true;
 -      texture[0] = 0;
 -      texture[1] = 0;
 -      texture[2] = 0;
        inv = new Inventory(PLAYER_INV_SIZE);
+       tex = new Texturec(3, "assets/player.png", "assets/player1.png", "assets/player2.png");
  }
  
  NPC::NPC(){   //sets all of the NPC specific traits on object creation
@@@ -247,10 -288,35 +285,18 @@@ unsigned int Structures::spawn(_TYPE t
                width =  50 * HLINE;
                height = 40 * HLINE;
  
+               /*
+                *      tempN is the amount of entities that will be spawned in the village. As of 10/21/2015 the village
+                *      can spawn bewteen 2 and 7 villagers for the starting hut.
+               */
                int tempN = (getRand() % 5 + 2); //amount of villagers that will spawn
                for(int i=0;i<tempN;i++){
+                       /*
+                        *                              This is where the entities actually spawn.
+                        *              A new entity is created with type NPC so polymorphism can be used
+                       */
                        entity.push_back(new NPC()); //create a new entity of NPC type
 -
 -                      //A new npc is created right here so the new entity can control it
 -                      npc.push_back(NPC()); //create new NPC
 -
 -                      /*
 -                       *      This is where the spawning gets sketchy...
 -                       *
 -                       *      We want to take the newest entity we spawned and set it equal to the new NPC
 -                       *      This seg faults, so for some odd reason we have to use the element of size
 -                       *      which shouldn't exist since we haven't created it. This entity is then set to the
 -                       *      same traits as the newest NPC, which we can access the last element in.
 -                       *
 -                       *      Then somehow we can set the same entity with size()-1 to spawn. But it works, so we're
 -                       *      not complaining. Although fixing would be nice. Now that it is mentioned...
 -                       *      TODO: FIX THIS BORK.
 -                      */
 -                      entity[entity.size()] = &npc[npc.size()-1]; //set the new entity to have the same traits as an NPC
 -                      entity[entity.size()-1]->spawn(loc.x + (float)(i - 5),100); //sets the position of the villager around the village
 +                      NPCp(entity[entity.size()-1])->spawn(loc.x + (float)(i - 5),100); //sets the position of the villager around the village
                }
                return entity.size();
        }