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;
}
};
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;
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);
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;