diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2016-01-13 07:55:06 -0500 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2016-01-13 07:55:06 -0500 |
commit | bf7d1d29029ca0afa4369bf95b8bd67c73fd5c45 (patch) | |
tree | 60d05a8cb5f0b90b245e0c4591b7ac1eae14d889 | |
parent | 9765c6303b763a60a2d917fc3c334b30e0fbbcfa (diff) |
fixed particles / indoors
-rw-r--r-- | include/world.h | 2 | ||||
-rw-r--r-- | main.cpp | 2 | ||||
-rw-r--r-- | src/gameplay.cpp | 2 | ||||
-rw-r--r-- | src/world.cpp | 31 |
4 files changed, 18 insertions, 19 deletions
diff --git a/include/world.h b/include/world.h index 27936f7..91fcf8a 100644 --- a/include/world.h +++ b/include/world.h @@ -289,7 +289,7 @@ float worldGetYBase(World *w); class IndoorWorld : public World { public: - World *outside; + World **outside; IndoorWorld(void); ~IndoorWorld(void); @@ -509,7 +509,7 @@ void mainLoop(void){ fps=1000/deltaTime; }else if(!(debugDiv%10)){ debugY = player->loc.y; - } + } render(); // Call the render loop; } diff --git a/src/gameplay.cpp b/src/gameplay.cpp index d647270..c4249a4 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -226,7 +226,7 @@ void initEverything(void){ if(!strcmp(l.name,wxml->Attribute("outside"))){ for(auto &b : l.ptr->build){ if(*b->inside == earth.back()){ - ((IndoorWorld *)*b->inside)->outside = l.ptr; + ((IndoorWorld *)*b->inside)->outside = &l.ptr; } } break; diff --git a/src/world.cpp b/src/world.cpp index 19e9fbc..3d7027d 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -421,28 +421,27 @@ void World::update(Player *p,unsigned int delta){ else if(e->vel.x > 0)e->left = false; } } - uint oh = 0; - for(auto &pa : particles){ - if(pa->kill(deltaTime)){ - delete pa; - particles.erase(particles.begin()+oh); - }else if(pa->canMove){ - pa->loc.y += pa->vely * deltaTime; - pa->loc.x += pa->velx * deltaTime; + + for(unsigned int i=0;i<particles.size();i++){ + if(particles[i]->kill(deltaTime)){ + delete particles[i]; + particles.erase(particles.begin()+i); + }else if(particles[i]->canMove){ + particles[i]->loc.y += particles[i]->vely * deltaTime; + particles[i]->loc.x += particles[i]->velx * deltaTime; for(auto &b : build){ if(b->bsubtype==FOUNTAIN){ - if(pa->loc.x >= b->loc.x && pa->loc.x <= b->loc.x+b->width){ - if(pa->loc.y <= b->loc.y + b->height*.25){ - delete pa; - particles.erase(particles.begin()+oh); + if(particles[i]->loc.x >= b->loc.x && particles[i]->loc.x <= b->loc.x + b->width){ + if(particles[i]->loc.y <= b->loc.y + b->height * .25){ + delete particles[i]; + particles.erase(particles.begin()+i); } } } } } - oh++; - }oh=0; + } if(ui::dialogImportant){ Mix_FadeOutMusic(2000); @@ -1214,13 +1213,13 @@ World *World::goInsideStructure(Player *p){ }else{ for(auto &b : ((World *)thing.back())->build){ if(*b->inside == this){ - //World *tmp = (World *)thing.back(); + World *tmp = (World *)thing.back(); p->loc.x = b->loc.x + (b->width / 2) - (p->width / 2); thing.erase(thing.end()-1); ui::toggleBlackFast(); ui::waitForCover(); ui::toggleBlackFast(); - return ((IndoorWorld *)(*b->inside))->outside; + return tmp; } } } |