]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
Ass
authordrumsetmonkey <abelleisle@roadrunner.com>
Wed, 13 Jan 2016 12:53:55 +0000 (07:53 -0500)
committerdrumsetmonkey <abelleisle@roadrunner.com>
Wed, 13 Jan 2016 12:53:55 +0000 (07:53 -0500)
1  2 
include/entities.h
main.cpp
src/entities.cpp
src/ui.cpp
src/world.cpp
xml/playerSpawnHill1.xml

index fe0d014d78136b111656dc5bcf33c718fa45088d,1e6d31649c6e30f813ae23c13db41e302a7da92e..8ef7c90c1712eec55de48f217a703ce91e1315d0
@@@ -82,11 -81,9 +82,11 @@@ public
        float velx;
        float vely;
        Color color;
--      int duration;
++      float duration;
        bool canMove;
 -      Particles(float x, float y, float w, float h, float vx, float vy, Color c, int d){
 +      bool fountain;
 +      bool gravity;
-       Particles(float x, float y, float w, float h, float vx, float vy, Color c, int d){
++      Particles(float x, float y, float w, float h, float vx, float vy, Color c, float d){
                loc.x = (x);
                loc.y = (y);
                width = (w);
                color.green = (c.green);
                color.blue = (c.blue);
                duration = d;
-       ~Particles(){}
 +              fountain = false;
 +              gravity = true;
 +      }
 -      ~Particles(){}
++      ~Particles(){
++
+       }
        void draw(){
                glColor3f(color.red,color.green,color.blue);
                glRectf(loc.x,loc.y,loc.x+width,loc.y+height);
        }
        bool kill(float delta){
                duration -= delta;
-               if(duration <= 0){
 -              if(duration <= 0)
++              if(duration <= 0.0f){
                        return true;
 +              }
                else return false;
        }
  };
diff --cc main.cpp
Simple merge
Simple merge
diff --cc src/ui.cpp
index 4212307a80a1610bb58858cb468b0452f6a43c9c,616eb82aa6c02afd4bfe2a798fcd69927933b45c..46702204ffb2578e284d2a4dc1d6e59dc8e92e04
@@@ -823,26 -824,7 +824,26 @@@ DONE
                                        currentWorld->addLight({player->loc.x + SCREEN_WIDTH/2, player->loc.y},{1.0f,1.0f,1.0f});
                                        break;
                                case SDLK_g:
-                                       currentWorld->addStructure(LAMP_POST, player->loc.x, player->loc.y, currentWorld);
+                                       //currentWorld->addStructure(LAMP_POST, player->loc.x, player->loc.y, currentWorld);
 +                                      break;
 +                              case SDLK_h:
-                                       currentWorld->addStructure(TOWN_HALL, player->loc.x, player->loc.y, currentWorld);
++                                      //currentWorld->addStructure(TOWN_HALL, player->loc.x, player->loc.y, currentWorld);
 +                                      break;
 +                              case SDLK_j:
-                                       currentWorld->addStructure(FOUNTAIN, player->loc.x, player->loc.y, currentWorld);
++                                      //currentWorld->addStructure(FOUNTAIN, player->loc.x, player->loc.y, currentWorld);
 +                                      break;
 +                              case SDLK_v:
-                                       currentWorld->addVillage(player->loc.x, player->loc.y, 5, 10, 100, currentWorld);
++                                      //currentWorld->addVillage(player->loc.x, player->loc.y, 5, 10, 100, currentWorld);
 +                                      break;
 +                              case SDLK_b:
-                                       currentWorld->addStructure(FIRE_PIT, player->loc.x, player->loc.y, currentWorld);
++                                      currentWorld->addStructure(FIRE_PIT, player->loc.x, player->loc.y, NULL);
 +                                      break;
 +                              case SDLK_F12:
 +                                      std::cout << "Took screenshot" << std::endl;
 +                                      // Make the BYTE array, factor of 3 because it's RBG.
 +                                      static GLubyte* pixels = new GLubyte[ 3 * SCREEN_WIDTH * SCREEN_HEIGHT];
 +                                      glReadPixels(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, GL_RGB, GL_UNSIGNED_BYTE, pixels);
 +
                                        break;
                                default:
                                        break;
diff --cc src/world.cpp
index e56720d0b1e4ae7dbe26f32dadcd4f771eb74da0,19e9fbc3e07ab8f6d8bc97347d16bfb71de5a466..58606e5cd4560f2c9cc0a1e4f31786d7bdd02c06
@@@ -426,11 -421,11 +424,12 @@@ void World::update(Player *p,unsigned i
           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);
 +                      //delete pa;
-                       particles.erase(particles.begin()+oh);
++                      //particles.erase(particles.begin()+oh);
++                      std::cout << pa.duration;
++                      std::cout << particles[oh].duration;
                }else if(pa->canMove){
                        pa->loc.y += pa->vely * deltaTime;
                        pa->loc.x += pa->velx * deltaTime;
                                        }
                                }
                        }
-               }oh++;
-       }oh=0;
+               }
 -              oh++;
 -      }oh=0;
++      }
        
        if(ui::dialogImportant){
                Mix_FadeOutMusic(2000);
@@@ -1049,7 -1046,7 +1048,7 @@@ LOOOOP
                        part->velx = 0;
                        part->canMove = false;
                }else{
-                       if(!part->gravity && part->vely > -2)part->vely-=.003 * deltaTime;
 -                      if(part->vely > -2)part->vely-=.003 * deltaTime;
++                      if(part->gravity && part->vely > -2)part->vely-=.003 * deltaTime;
                }
                what++;
        }what=0;
Simple merge