aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2016-01-13 08:31:26 -0500
committerdrumsetmonkey <abelleisle@roadrunner.com>2016-01-13 08:31:26 -0500
commit01c0446eaaf8f84a35ce5d5d82c55b7e155f7e43 (patch)
tree7c635297c09d6758ac17aa1f353190d1d9778c03
parent5ec498c3e583a8fe18fdc9fec683df8c2541b28c (diff)
parentbf7d1d29029ca0afa4369bf95b8bd67c73fd5c45 (diff)
Added fire
-rw-r--r--include/entities.h2
-rw-r--r--include/world.h2
-rw-r--r--main.cpp5
-rw-r--r--src/entities.cpp1
-rw-r--r--src/gameplay.cpp2
-rw-r--r--src/world.cpp45
6 files changed, 32 insertions, 25 deletions
diff --git a/include/entities.h b/include/entities.h
index 8ef7c90..412ec42 100644
--- a/include/entities.h
+++ b/include/entities.h
@@ -86,6 +86,7 @@ public:
bool canMove;
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);
@@ -99,6 +100,7 @@ public:
duration = d;
fountain = false;
gravity = true;
+ behind = false;
}
~Particles(){
diff --git a/include/world.h b/include/world.h
index 27936f7..91fcf8a 100644
--- a/include/world.h
+++ b/include/world.h
@@ -289,7 +289,7 @@ float worldGetYBase(World *w);
class IndoorWorld : public World {
public:
- World *outside;
+ World **outside;
IndoorWorld(void);
~IndoorWorld(void);
diff --git a/main.cpp b/main.cpp
index bd3d89b..bff283d 100644
--- 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;
}
@@ -950,8 +950,9 @@ void logic(){
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;
diff --git a/src/entities.cpp b/src/entities.cpp
index 817a1b0..01b379b 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -505,6 +505,7 @@ unsigned int Structures::spawn(BUILD_SUB sub, float x, float y, World *oi){
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;
diff --git a/src/gameplay.cpp b/src/gameplay.cpp
index d647270..c4249a4 100644
--- a/src/gameplay.cpp
+++ b/src/gameplay.cpp
@@ -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;
diff --git a/src/world.cpp b/src/world.cpp
index 58606e5..6ee7255 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -424,21 +424,21 @@ void World::update(Player *p,unsigned int delta){
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);
}
}
}
@@ -657,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();
}
@@ -781,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();
@@ -1125,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){
@@ -1216,13 +1219,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;
}
}
}