diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/entities.cpp | 26 | ||||
-rw-r--r-- | src/ui.cpp | 19 | ||||
-rw-r--r-- | src/world.cpp | 20 |
3 files changed, 47 insertions, 18 deletions
diff --git a/src/entities.cpp b/src/entities.cpp index b4c34d9..817a1b0 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -19,7 +19,8 @@ std::string sTexLoc[] = { "assets/townhall.png", "assets/house1.png", "assets/house1.png", "assets/fountain1.png", - "assets/lampPost1.png"}; + "assets/lampPost1.png", + "assets/brazzier.png"}; void getRandomName(Entity *e){ unsigned int tempNum,max=0; @@ -453,9 +454,6 @@ unsigned int Structures::spawn(BUILD_SUB sub, float x, float y, World *oi){ alive = true; bsubtype = sub; - int s = -1; - s = sub; - inWorld = oi; /* @@ -471,9 +469,15 @@ unsigned int Structures::spawn(BUILD_SUB sub, float x, float y, World *oi){ "assets/lampPost1.png")*/; unsigned int tempN = (getRand() % 5 + 2); - switch(s){ + switch(sub){ + case TOWN_HALL: + tex = new Texturec(1, sTexLoc[sub].c_str()); + width = 50 * HLINE; + height = 40 * HLINE; + + break; case HOUSE: - tex = new Texturec(1, sTexLoc[s].c_str()); + tex = new Texturec(1, sTexLoc[sub].c_str()); width = 50 * HLINE; height = 40 * HLINE; for(unsigned int i = 0;i < tempN;i++){ @@ -484,20 +488,24 @@ unsigned int Structures::spawn(BUILD_SUB sub, float x, float y, World *oi){ */ oi->addNPC(loc.x + i * HLINE ,100); - } break; case FOUNTAIN: - tex = new Texturec(1, sTexLoc[s].c_str()); + tex = new Texturec(1, sTexLoc[sub].c_str()); width = 50 * HLINE; height = 40 * HLINE; break; case LAMP_POST: - tex = new Texturec(1, sTexLoc[s].c_str()); + tex = new Texturec(1, sTexLoc[sub].c_str()); width = 10 * HLINE; 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; + break; default: break; } @@ -826,6 +826,25 @@ DONE: case SDLK_g: //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); + break; + case SDLK_j: + //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); + break; + case SDLK_b: + 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 --git a/src/world.cpp b/src/world.cpp index 19e9fbc..58606e5 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -229,9 +229,12 @@ void World::deleteEntities(void){ entity.pop_back(); } while(!particles.empty()){ - delete particles.back(); + //delete particles.back(); particles.pop_back(); } + while(!light.empty()){ + light.pop_back(); + } } World::~World(void){ @@ -421,17 +424,17 @@ 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); + //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(auto &b : build){ - if(b->bsubtype==FOUNTAIN){ + 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; @@ -441,8 +444,7 @@ void World::update(Player *p,unsigned int delta){ } } } - oh++; - }oh=0; + } if(ui::dialogImportant){ Mix_FadeOutMusic(2000); @@ -1046,7 +1048,7 @@ LOOOOP: part->velx = 0; part->canMove = false; }else{ - if(part->vely > -2)part->vely-=.003 * deltaTime; + if(part->gravity && part->vely > -2)part->vely-=.003 * deltaTime; } what++; }what=0; |