diff options
Diffstat (limited to 'src/entities.cpp')
-rw-r--r-- | src/entities.cpp | 38 |
1 files changed, 9 insertions, 29 deletions
diff --git a/src/entities.cpp b/src/entities.cpp index 092ab7b..7a4da65 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -2,7 +2,7 @@ #include <ui.h> extern std::vector<Entity*>entity; -extern std::vector<NPC>npc; +//extern std::vector<NPC>npc; extern std::vector<Structures>build; extern FILE* names; @@ -13,14 +13,14 @@ void Entity::spawn(float x, float y){ //spawns the entity you pass to it based o loc.y = y; vel.x = 0; vel.y = 0; - right = false; - left = false; - near = false; - ticksToUse = 0; - canMove = true; - ground = false; alive = true; - if(!maxHealth)health = maxHealth = 50; + right = true; + left = false; + near = false; + canMove = true; + ground = false; + ticksToUse = 0; + if(!maxHealth)health = maxHealth = 1; name = (char*)malloc(16); getName(); } @@ -36,9 +36,6 @@ Player::Player(){ //sets all of the player specific traits on object creation 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"); } @@ -299,24 +296,7 @@ unsigned int Structures::spawn(_TYPE t, float x, float y){ //spawns a structure * 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(); } |