From: drumsetmonkey Date: Wed, 13 Jan 2016 12:53:55 +0000 (-0500) Subject: Ass X-Git-Url: https://code.bitgloo.com/?a=commitdiff_plain;h=5ec498c3e583a8fe18fdc9fec683df8c2541b28c;p=clyne%2Fgamedev.git Ass --- 5ec498c3e583a8fe18fdc9fec683df8c2541b28c diff --cc include/entities.h index fe0d014,1e6d316..8ef7c90 --- a/include/entities.h +++ b/include/entities.h @@@ -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); @@@ -97,19 -94,16 +97,21 @@@ color.green = (c.green); color.blue = (c.blue); duration = d; + fountain = false; + gravity = true; + } - ~Particles(){} ++ ~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 src/ui.cpp index 4212307,616eb82..4670220 --- a/src/ui.cpp +++ b/src/ui.cpp @@@ -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 e56720d,19e9fbc..58606e5 --- a/src/world.cpp +++ b/src/world.cpp @@@ -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; @@@ -444,8 -440,9 +443,8 @@@ } } } - }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;