]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
Fire Pit
authordrumsetmonkey <abelleisle@roadrunner.com>
Wed, 13 Jan 2016 12:31:16 +0000 (07:31 -0500)
committerdrumsetmonkey <abelleisle@roadrunner.com>
Wed, 13 Jan 2016 12:31:16 +0000 (07:31 -0500)
include/entities.h
include/world.h
main.cpp
src/common.cpp
src/entities.cpp
src/ui.cpp
src/world.cpp
xml/playerSpawnHill1.xml

index d7ad2c0a16bc6a2ecc63033616fd98e300719551..fe0d014d78136b111656dc5bcf33c718fa45088d 100644 (file)
@@ -43,7 +43,8 @@ enum BUILD_SUB{
        HOUSE3 = 3,
        HOUSE4 = 4,
        FOUNTAIN = 5,
-       LAMP_POST = 6
+       LAMP_POST = 6,
+       FIRE_PIT = 7
 };
 
 typedef struct {
@@ -83,6 +84,8 @@ public:
        Color color;
        int duration;
        bool canMove;
+       bool fountain;
+       bool gravity;
        Particles(float x, float y, float w, float h, float vx, float vy, Color c, int d){
                loc.x = (x);
                loc.y = (y);
@@ -94,6 +97,8 @@ public:
                color.green = (c.green);
                color.blue = (c.blue);
                duration = d;
+               fountain = false;
+               gravity = true;
        }
        ~Particles(){}
        void draw(){
@@ -102,8 +107,9 @@ public:
        }
        bool kill(float delta){
                duration -= delta;
-               if(duration <= 0)
+               if(duration <= 0){
                        return true;
+               }
                else return false;
        }
 };
index ef373652402708dcffee0b1f4df8989dc5104e68..7f22cbaf19fbf327191eec6378eb999ccd41a379 100644 (file)
@@ -177,7 +177,7 @@ public:
        std::vector<Light        >  light;
        
        void addStructure(BUILD_SUB sub,float x,float y,World *inside);
-       void addVillage(int bCount, int npcMin, int npcMax,World *inside);
+       void addVillage(int x, int y, int bCount, int npcMin, int npcMax,World *inside);
        void addMob(int t,float x,float y);
        void addMob(int t,float x,float y,void (*hey)(Mob *));
        void addNPC(float x,float y);
index 79c7250dab313f1b594452846281b9b80d6062dd..8254d9bb7bca4c267fbb5e656175b8eff0583757 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -937,17 +937,26 @@ 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) + 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->particles.back()->gravity = false;
+                               }
+                               break;
+                       default: break;
                }
        }
        
index 63077908dbef255cb81eb4bec7c77de88b09d089..ead2dc36a1f950d914e2bf123dfa99d2e6f51149 100644 (file)
@@ -84,7 +84,6 @@ void strVectorSortAlpha(std::vector<std::string> *v){
                change = false;
                for(unsigned int i=0;i<v->size()-1;i++){
                        if(v[0][i] > v[0][i+1]){
-                               std::cout<<"swap "<<v[0][i]<<" <-> "<<v[0][i+1]<<std::endl;
                                std::swap(v[0][i],v[0][i+1]);
                                change = true;
                        }
index 627946be0d74fa163085f5478e1d6dc84f81fd30..abb1427a7a335866b3ea3504dd9935ad69c931d4 100644 (file)
@@ -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;
        }
index 0d01033d0f6a2da55724c4ff6bb049a2146fe321..4212307a80a1610bb58858cb468b0452f6a43c9c 100644 (file)
@@ -824,6 +824,25 @@ DONE:
                                        break;
                                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, currentWorld);
+                                       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;
index 451a0223f7ee4b5b93290c4115c28990bf85d65b..e56720d0b1e4ae7dbe26f32dadcd4f771eb74da0 100644 (file)
@@ -231,9 +231,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){
@@ -426,14 +429,13 @@ void World::update(Player *p,unsigned int delta){
        uint oh = 0;
        for(auto &pa : particles){
                if(pa->kill(deltaTime)){
-                       delete pa;
+                       //delete pa;
                        particles.erase(particles.begin()+oh);
                }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;
@@ -442,8 +444,7 @@ void World::update(Player *p,unsigned int delta){
                                        }
                                }
                        }
-               }
-               oh++;
+               }oh++;
        }oh=0;
        
        if(ui::dialogImportant){
@@ -1048,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;
@@ -1067,21 +1068,12 @@ void World::addStructure(BUILD_SUB sub, float x,float y,World *inside){
        entity.push_back(build.back());
 }
        
-void World::addVillage(int bCount, int npcMin, int npcMax,World *inside){
+void World::addVillage(int x, int y, int bCount, int npcMin, int npcMax,World *inside){
        std::cout << npcMin << ", " << npcMax << std::endl;
-       //int xwasd;
-       for(int i = 0; i < bCount; i++){
-               addStructure(HOUSE,x_start + (i * 300),100,inside);
-               /*std::cout<<"1\n";
-               HERE:
-               xwasd = (rand()%(int)x+1000*HLINE);
-               for(auto &bu : build){
-                       if(xwasd > bu->loc.x && xwasd < bu->loc.x+bu->width)goto HERE;
-               }
-               std::cout<<"2\n";
-               addStructure(t,HOUSE,xwasd,y,inside);
-               std::cout<<"3\n";*/
-       }
+       this->addStructure(TOWN_HALL, x,y, inside);
+       bCount--;
+       this->addStructure(LAMP_POST, x-3*HLINE,y, this);
+       this->addStructure(LAMP_POST, x+53*HLINE,y, this);
 }
 void World::addMob(int t,float x,float y){
        mob.push_back(new Mob(t));
index 5ad31b0e1cdb70d958a2d4d8e64a2f1a10c05bfc..c8ea8277c2d370e4c211f6f06eef6e813b5ac30c 100644 (file)
@@ -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>