diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2015-11-17 08:38:51 -0500 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2015-11-17 08:38:51 -0500 |
commit | fcf3e396c57b285b621624f63f9acd6515c58ef9 (patch) | |
tree | 03969def5fbea60e9003e56c94ccca1492eebe26 /src/world.cpp | |
parent | 20b29fccb6da62d5a07a02477fabac3a80d350dd (diff) |
cutscenes, arenas
Diffstat (limited to 'src/world.cpp')
-rw-r--r-- | src/world.cpp | 89 |
1 files changed, 77 insertions, 12 deletions
diff --git a/src/world.cpp b/src/world.cpp index 2757471..335bda6 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -286,9 +286,7 @@ LOOP2: /* * Draw the layer up until the grass portion, which is done later. */ - /* - * TODO: CLYNE CHANGE THE NAME OF THIS - */ + bool hey=false; glBegin(GL_QUADS); for(i=is;i<ie-GEN_INC;i++){ @@ -449,18 +447,51 @@ LOOP2: } void World::singleDetect(Entity *e){ - unsigned int i; + unsigned int i,j; /* * Kill any dead entities. */ - if(e->alive&&e->health<=0){ - - e->alive=false; - std::cout<<"Killing entity..."<<std::endl; + if(!e->alive||e->health<=0){ + + for(i=0;i<entity.size();i++){ + if(entity[i]==e){ + entity.erase(entity.begin()+i); + switch(e->type){ + case STRUCTURET: + for(j=0;j<build.size();j++){ + if(build[j]==e){ + build.erase(build.begin()+j); + return; + } + } + break; + case NPCT: + for(j=0;j<npc.size();j++){ + if(npc[j]==e){ + npc.erase(npc.begin()+j); + return; + } + } + break; + case MOBT: + for(j=0;j<mob.size();j++){ + if(mob[j]==e){ + mob.erase(mob.begin()+j); + return; + } + } + break; + } + return; + } + } + + std::cout<<"RIP "<<e->name<<"."<<std::endl; + exit(0); + return; - } /* @@ -469,6 +500,8 @@ void World::singleDetect(Entity *e){ if(e->alive){ + if(e->type == MOBT && Mobp(e)->subtype == MS_TRIGGER)return; + /* * Calculate the line that this entity is currently standing on. */ @@ -577,6 +610,14 @@ void World::addMob(int t,float x,float y){ entity.push_back(mob.back()); } +void World::addMob(int t,float x,float y,void (*hey)()){ + mob.push_back(new Mob(t)); + mob.back()->spawn(x,y); + mob.back()->hey = hey; + + entity.push_back(mob.back()); +} + void World::addNPC(float x,float y){ npc.push_back(new NPC()); npc.back()->spawn(x,y); @@ -727,9 +768,33 @@ void IndoorWorld::draw(Player *p){ p->draw(); } -void Arena::drawDoor(void){ +extern bool inBattle; + +Arena::Arena(World *leave,Player *p){ + generate(300); + door.y = line[299].y; + door.x = 100; + exit = leave; + + npc.push_back(new NPC()); + entity.push_back(npc.back()); + entity.back()->spawn(door.x,door.y); + entity.back()->width = HLINE * 12; + entity.back()->height = HLINE * 16; + + inBattle = true; + pxy = p->loc; } -World *Arena::exitArena(void){ - return this; +World *Arena::exitArena(Player *p){ + npc[0]->loc.x = door.x; + npc[0]->loc.y = door.y; + if(p->loc.x + p->width / 2 > door.x && + p->loc.x + p->width / 2 < door.x + HLINE * 12 ){ + inBattle = false; + p->loc = pxy; + return exit; + }else{ + return this; + } } |