Player::Player(){ //sets all of the player specific traits on object creation
width = HLINE * 10;
height = HLINE * 16;
- speed = 1;
+
type = PLAYERT; //set type to player
-- subtype = 0;
- maxHealth = 100;
- health = maxHealth;
- alive = true;
- ground = false;
- near = true;
- inv = new Inventory(PLAYER_INV_SIZE);
-
++ subtype = 0;
+ health = maxHealth = 100;
+ speed = 1;
-
- tex = new Texturec(3, "assets/player.png", "assets/player1.png", "assets/player2.png");
+ tex = new Texturec(3, "assets/player1.png", "assets/player.png", "assets/player2.png");
+ inv = new Inventory(PLAYER_INV_SIZE);
}
NPC::NPC(){ //sets all of the NPC specific traits on object creation
tex = new Texturec(1,"assets/house1.png");
}
-Mob::Mob(){
+Mob::Mob(int sub){
width = HLINE * 10;
height = HLINE * 8;
- speed = 1;
-
type = MOBT; //sets type to MOB
- subtype = 1; //SKIRL
-
- tex = new Texturec(2, "assets/rabbit.png", "assets/rabbit.png1");
+ subtype = sub; //SKIRL
- alive = true;
- canMove = true;
- near = false;
+ if(subtype == 1){//RABBIT
+ tex = new Texturec(2, "assets/rabbit.png", "assets/rabbit1.png");
+ }else if(subtype == 2){//BIRD
+ //add bird textures and bird things
+ }
inv = new Inventory(NPC_INV_SIZE);
}
player=new Player();
player->spawn(0,100);
- // Make structures
- entity.push_back(new Entity());
+ /*
+ * Create a structure (this will create villagers when spawned).
+ */
+
build.push_back(new Structures());
- entity[0]=build[0];
-
- build[0]->spawn(STRUCTURET,(rand()%120*HLINE),10);
+ entity.push_back(build.back());
+ build.back()->spawn(STRUCTURET,(rand()%120*HLINE),10);
+
+ /*
+ * Generate an indoor world and link the structure to it.
+ */
+
IndoorWorld *iw=new IndoorWorld();
iw->generate(200);
- build[0]->inside=iw;
+ build.back()->inside=iw;
- entity.push_back(new Mob(1)); //create a new entity of NPC type
- mob.push_back(Mob(1)); //create new NPC
- entity[entity.size()] = &mob[mob.size()-1]; //set the new entity to have the same traits as an NPC
- entity[entity.size()-1]->spawn(200,100); //sets the position of the villager around the village
- entity.pop_back();
-
+ /*
+ * Spawn a mob.
- */
-
- mob.push_back(new Mob());
++ */
++ mob.push_back(new Mob(1));
+ entity.push_back(mob.back());
+ mob.back()->spawn(200,100);
+ /*
+ * Link all the entities that were just created to the initial world, and setup a test AI function.
+ */
NPCp(entity[1])->addAIFunc(giveTestQuest,false);
- for(i=0;i<entity.size()+1;i++){
- entity[i]->inWorld=test;
+
+ for(i=0;i<entity.size();i++){
+ entity[i]->inWorld=currentWorld;
}
}