diff options
Diffstat (limited to 'src/world.cpp')
-rw-r--r-- | src/world.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/world.cpp b/src/world.cpp index 3d7027d..6ee7255 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -229,9 +229,12 @@ void World::deleteEntities(void){ entity.pop_back(); } while(!particles.empty()){ - delete particles.back(); + //delete particles.back(); particles.pop_back(); } + while(!light.empty()){ + light.pop_back(); + } } World::~World(void){ @@ -421,7 +424,7 @@ void World::update(Player *p,unsigned int delta){ else if(e->vel.x > 0)e->left = false; } } - + for(unsigned int i=0;i<particles.size();i++){ if(particles[i]->kill(deltaTime)){ delete particles[i]; @@ -654,7 +657,8 @@ LOOP2: * Draw structures. We draw structures behind the dirt/grass so that the building's * corners don't stick out. */ - + + for(auto &part : particles){if(part->behind)part->draw();} for(auto &b : current->build){ b->draw(); } @@ -778,7 +782,7 @@ LOOP2: /* * Draw non-structure entities. */ - for(auto &part : particles){part->draw();} + for(auto &part : particles){if(!part->behind)part->draw();} for(auto &n : current->npc){ n->loc.y+=(yoff-DRAW_Y_OFFSET); n->draw(); @@ -1045,7 +1049,7 @@ LOOOOP: part->velx = 0; part->canMove = false; }else{ - if(part->vely > -2)part->vely-=.003 * deltaTime; + if(part->gravity && part->vely > -2)part->vely-=.003 * deltaTime; } what++; }what=0; @@ -1122,9 +1126,11 @@ void World::addParticle(float x, float y, float w, float h, float vx, float vy, } void World::addLight(vec2 loc, Color color){ - light.push_back(Light()); - light.back().loc = loc; - light.back().color = color; + if(light.size() < 64){ + light.push_back(Light()); + light.back().loc = loc; + light.back().color = color; + } } /*void World::removeObject(Object i){ |