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
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();
}