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;
++ bool behind;
+ 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;
+ fountain = false;
+ gravity = true;
++ behind = false;
+ }
+ ~Particles(){
+
}
- ~Particles(){}
void draw(){
glColor3f(color.red,color.green,color.blue);
glRectf(loc.x,loc.y,loc.x+width,loc.y+height);
}
}
for(auto &b : currentWorld->build){
- if(b->bsubtype == FOUNTAIN){
- for(int r = 0; r < (rand()%20)+10;r++)
- currentWorld->addParticle(rand()%HLINE*3 + b->loc.x + b->width/2,b->loc.y + b->height, HLINE,HLINE, rand()%2 == 0?-(rand()%7)*.01:(rand()%7)*.01,((4+rand()%6)*.05), {0,0,1.0f}, 2500);
+ switch(b->bsubtype){
+ case FOUNTAIN:
+ for(int r = 0; r < (rand()%20)+10;r++){
+ currentWorld->addParticle(rand()%HLINE*3 + b->loc.x + b->width/2,b->loc.y + b->height, HLINE,HLINE, rand()%2 == 0?-(rand()%7)*.01:(rand()%7)*.01,((4+rand()%6)*.05), {0,0,1.0f}, 2500);
+ currentWorld->particles.back()->fountain = true;
+ }
+ break;
+ case FIRE_PIT:
+ for(int r = 0; r < (rand()%20)+10;r++){
- currentWorld->addParticle(rand()%(int)(b->width) + b->loc.x, b->loc.y, HLINE, HLINE, rand()%2 == 0?-(rand()%7)*.01:(rand()%7)*.01,((4+rand()%6)*.05), {1.0f,0.0f,0.0f}, 100);
++ currentWorld->addParticle(rand()%(int)(b->width/2) + b->loc.x+b->width/4, b->loc.y+3*HLINE, HLINE, HLINE, rand()%2 == 0?-(rand()%7)*.01:(rand()%7)*.01,((4+rand()%6)*.05), {1.0f,0.0f,0.0f}, 100);
+ currentWorld->particles.back()->gravity = false;
++ currentWorld->particles.back()->behind = true;
+ }
+ break;
+ default: break;
}
}
height = 40 * HLINE;
oi->addLight({x+SCREEN_WIDTH/2,y+30*HLINE},{1.0f,1.0f,1.0f});
break;
+ case FIRE_PIT:
+ tex = new Texturec(1, sTexLoc[sub].c_str());
+ width = 12 * HLINE;
+ height = 12 * HLINE;
++ oi->addLight({x+SCREEN_WIDTH/2,y},{1.0f,1.0f,1.0f});
+ break;
default:
break;
}
else if(e->vel.x > 0)e->left = false;
}
}
- for(auto &pa : particles){
- if(pa->kill(deltaTime)){
- //delete pa;
- //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;
-
++
+ 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 && pa->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(b->bsubtype==FOUNTAIN){
+ 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);
}
}
}
* 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();
}
/*
* 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();
}
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){