diff options
-rw-r--r-- | include/entities.h | 20 | ||||
-rw-r--r-- | main.cpp | 20 | ||||
-rw-r--r-- | src/entities.cpp | 27 | ||||
-rw-r--r-- | src/ui.cpp | 19 | ||||
-rw-r--r-- | src/world.cpp | 22 | ||||
-rw-r--r-- | xml/playerSpawnHill1.xml | 2 |
6 files changed, 82 insertions, 28 deletions
diff --git a/include/entities.h b/include/entities.h index 1e6d316..412ec42 100644 --- a/include/entities.h +++ b/include/entities.h @@ -43,7 +43,8 @@ enum BUILD_SUB{ HOUSE3 = 3, HOUSE4 = 4, FOUNTAIN = 5, - LAMP_POST = 6 + LAMP_POST = 6, + FIRE_PIT = 7 }; typedef struct { @@ -81,9 +82,12 @@ 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; + 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); @@ -94,16 +98,22 @@ public: 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); } bool kill(float delta){ duration -= delta; - if(duration <= 0) + if(duration <= 0.0f){ return true; + } else return false; } }; @@ -935,17 +935,27 @@ void logic(){ o->interact(); objectInteracting=false; } - } } - } } } 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/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 b4c34d9..01b379b 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,25 @@ 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; + oi->addLight({x+SCREEN_WIDTH/2,y},{1.0f,1.0f,1.0f}); + 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 3d7027d..6ee7255 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,7 +424,7 @@ void World::update(Player *p,unsigned int delta){ else if(e->vel.x > 0)e->left = false; } } - + for(unsigned int i=0;i<particles.size();i++){ if(particles[i]->kill(deltaTime)){ delete particles[i]; @@ -654,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(); } @@ -778,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(); @@ -1045,7 +1049,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; @@ -1122,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){ diff --git a/xml/playerSpawnHill1.xml b/xml/playerSpawnHill1.xml index 12d55fc..a9bde4f 100644 --- a/xml/playerSpawnHill1.xml +++ b/xml/playerSpawnHill1.xml @@ -37,6 +37,6 @@ </text> <text id="1" > - My name's Johnny. + ****FREE WIRELESS KEYBOARD**JAM PACKED FULL OF GOODIES TOO MUCH TO MENTION** SUPPLIED WITH ANDROID TV BOX BLACK **CUSTOM BUILT XBMC APPLE TV AIRPLAY SYSTEM ** FULLY LOADED QUAD CORE**4K KITKAT ULTRA-HD XBMC ALL FREE ONE OFF PURCHASE FOR THE BOX FREE TV FREE MUSIC FREE MOVIES FREE SPORTS FREE GAMES FREE XXX NEXT GENERATION ANDROID TV BOX FASTEST ON THE MARKET TO DATE RELEASE 2015 FREE WORLDWIDE TV AT YOUR FINGER TIPS WIFI AND ETHERNET CONNECTION 5 Ghz WIFI </text> </Dialog> |