]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
fixed particles / indoors
authorClyne Sullivan <tullivan99@gmail.com>
Wed, 13 Jan 2016 12:55:06 +0000 (07:55 -0500)
committerClyne Sullivan <tullivan99@gmail.com>
Wed, 13 Jan 2016 12:55:06 +0000 (07:55 -0500)
include/world.h
main.cpp
src/gameplay.cpp
src/world.cpp

index 27936f7c67b3c3af7c65e34dd00e7cca3a53634b..91fcf8ad5fcf093a91f6915fe7224ac9133cbe43 100644 (file)
@@ -289,7 +289,7 @@ float worldGetYBase(World *w);
  
 class IndoorWorld : public World {
 public:
-       World *outside;
+       World **outside;
        IndoorWorld(void);
        ~IndoorWorld(void);
        
index c3638757b02e6619c4bae62e506d04d1e4c3c5ac..dba36052ffa12cba4a6ab2f7ba2763042df36690 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -509,7 +509,7 @@ void mainLoop(void){
                        fps=1000/deltaTime;
        }else if(!(debugDiv%10)){
                debugY = player->loc.y;
-       }
+       }       
 
        render();       // Call the render loop;
 }
index d6472707ea95b811cc8f4001ce524801a8ce740b..c4249a44f5e9604932aa6d45407f8047cc7e2a5c 100644 (file)
@@ -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;
index 19e9fbc3e07ab8f6d8bc97347d16bfb71de5a466..3d7027dc1dfbd5515e03d23e1c9b2d06dcd37ebb 100644 (file)
@@ -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;
                        }
                }
        }