]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
Village work
authordrumsetmonkey <abelleisle@roadrunner.com>
Fri, 19 Feb 2016 23:33:29 +0000 (18:33 -0500)
committerdrumsetmonkey <abelleisle@roadrunner.com>
Fri, 19 Feb 2016 23:33:29 +0000 (18:33 -0500)
13 files changed:
assets/style/classic/bg/bgFarTreeTile.png [deleted file]
assets/style/classic/bg/bgFrontTreeTile.png [deleted file]
assets/style/classic/bg/bgMidTreeTile.png [deleted file]
assets/style/rustic/bg/bgFarTreeTile.png [deleted file]
assets/style/rustic/bg/bgFrontTreeTile.png [deleted file]
assets/style/rustic/bg/bgMidTreeTile.png [deleted file]
include/common.h
include/ui.h
include/world.h
main.cpp
src/ui.cpp
src/world.cpp
xml/playerSpawnHill1.xml

diff --git a/assets/style/classic/bg/bgFarTreeTile.png b/assets/style/classic/bg/bgFarTreeTile.png
deleted file mode 100644 (file)
index 07546a5..0000000
Binary files a/assets/style/classic/bg/bgFarTreeTile.png and /dev/null differ
diff --git a/assets/style/classic/bg/bgFrontTreeTile.png b/assets/style/classic/bg/bgFrontTreeTile.png
deleted file mode 100644 (file)
index 7fc7450..0000000
Binary files a/assets/style/classic/bg/bgFrontTreeTile.png and /dev/null differ
diff --git a/assets/style/classic/bg/bgMidTreeTile.png b/assets/style/classic/bg/bgMidTreeTile.png
deleted file mode 100644 (file)
index 126723e..0000000
Binary files a/assets/style/classic/bg/bgMidTreeTile.png and /dev/null differ
diff --git a/assets/style/rustic/bg/bgFarTreeTile.png b/assets/style/rustic/bg/bgFarTreeTile.png
deleted file mode 100644 (file)
index 07546a5..0000000
Binary files a/assets/style/rustic/bg/bgFarTreeTile.png and /dev/null differ
diff --git a/assets/style/rustic/bg/bgFrontTreeTile.png b/assets/style/rustic/bg/bgFrontTreeTile.png
deleted file mode 100644 (file)
index 7fc7450..0000000
Binary files a/assets/style/rustic/bg/bgFrontTreeTile.png and /dev/null differ
diff --git a/assets/style/rustic/bg/bgMidTreeTile.png b/assets/style/rustic/bg/bgMidTreeTile.png
deleted file mode 100644 (file)
index 126723e..0000000
Binary files a/assets/style/rustic/bg/bgMidTreeTile.png and /dev/null differ
index 34260c95403cb18042703dd36e2af6c0378b3556..f141afd34d4a63d05dab424ebc4b0622f71accfb 100644 (file)
@@ -16,6 +16,7 @@
 #include <string>
 #include <fstream>     
 #include <thread>
+#include <mutex>
 
 #define GLEW_STATIC
 #include <GL/glew.h>
index 38a49328db2ee80169718ad5b34ff153fc8defb2..8d479a4c57293296982f3c00c9e9d6966b1f2ce4 100644 (file)
@@ -102,6 +102,7 @@ namespace ui {
        extern bool                      dialogBoxExists;
        extern unsigned char dialogOptChosen;
        extern bool dialogImportant;
+       extern bool dialogPassive;
 
        extern unsigned int textWrapLimit;
 
index 43da6fc923dd8651c9344ba83081c84748201cfd..edf7ebbc760aed4379698c05b7791d51850a28bc 100644 (file)
@@ -81,13 +81,29 @@ typedef struct line_t {
        unsigned char color;    /**< Lightness of dirt (brown) */
 } line_t;
 
+/*
+ * Handle all logic that has to do with villages
+ */
+
+
+struct Village{
+       std::string name;
+
+       std::vector<std::shared_ptr<Entity>>     entity;
+       std::vector<std::shared_ptr<Structures>> build;
+       std::vector<std::shared_ptr<NPC>>                npc;
+
+       Village(const char *meme){
+               name = meme;
+       }
+};
+
 /**
  * The world class. This class does everything a world should do.
  */
 
 class World {
 protected:
-       
        /**
         * The line array.
         * This array is created through 'new' in World::generate(), with an amount
@@ -113,6 +129,8 @@ protected:
         */
        
        void singleDetect(Entity *e);
+
+       static void villageLogic(World *world);
        
        /**
         * Empties all entity vectors.
@@ -244,6 +262,8 @@ public:
 
        std::vector<std::string  >  sTexLoc;
 
+       std::vector<Village>village;
+
        
        /**
         * NULLifies pointers and allocates necessary memory. This should be
index da1790fa5473a71c062a79b4af3db48173ad9f38..eb53c9936f39b7ed561bf791c0c69c0d26a56f72 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -237,6 +237,7 @@ int main(/*int argc, char *argv[]*/){
                return -1;
        }
        Mix_AllocateChannels(8);
+       updateConfig();
 
        // Run Mix_Quit when main returns
        atexit(Mix_Quit);
@@ -373,8 +374,6 @@ int main(/*int argc, char *argv[]*/){
        delete[] shaderSource;
        
        glEnable(GL_MULTISAMPLE);
-
-       Mix_Volume(0,VOLUME_MASTER);
        
        /*
         * Create all the worlds, entities, mobs, and the player. This function is defined in
@@ -524,7 +523,7 @@ void render(){
                if(player->loc.x - SCREEN_WIDTH/2 < currentWorld->getTheWidth() * -0.5f)
                        offset.x = ((currentWorld->getTheWidth() * -0.5f) + SCREEN_WIDTH / 2) + player->width / 2;
                if(player->loc.x + player->width + SCREEN_WIDTH/2 > currentWorld->getTheWidth() *  0.5f)
-                       offset.x = ((currentWorld->getTheWidth() *  0.5f) - SCREEN_WIDTH / 2);// + player->width / 2;
+                       offset.x = ((currentWorld->getTheWidth() *  0.5f) - SCREEN_WIDTH / 2) - player->width / 2;
        }
        
        if(player->loc.y > SCREEN_HEIGHT/2)
@@ -570,7 +569,7 @@ void render(){
        glMatrixMode(GL_PROJECTION);
        glPushMatrix();
        glLoadIdentity();
-       glOrtho((offset.x-SCREEN_WIDTH/2),(offset.x+SCREEN_WIDTH/2),offset.y-SCREEN_HEIGHT/2,offset.y+SCREEN_HEIGHT/2,-1,1);
+       glOrtho((offset.x-SCREEN_WIDTH/2),(offset.x+SCREEN_WIDTH/2),(offset.y-SCREEN_HEIGHT/2),(offset.y+SCREEN_HEIGHT/2),-1,1);
        glMatrixMode(GL_MODELVIEW);
        glPushMatrix();
        glLoadIdentity();
@@ -892,7 +891,7 @@ void logic(){
                        }
                }
        }
-       for(auto &b : currentWorld->build){
+       /*for(auto &b : currentWorld->build){
                switch(b->bsubtype){
                        case FOUNTAIN:
                                for(int r = 0; r < (rand()%25)+10;r++){
@@ -917,7 +916,7 @@ void logic(){
                                break;
                        default: break;
                }
-       }
+       }*/
        
        /*
         *      Switch between day and night (SUNNY and DARK) if necessary.
index e6ee98815ae80495d7992b9c287b9d6a7cdd3496..43706e77812d5ea79303bf520d72f2369fea0261 100644 (file)
@@ -52,7 +52,6 @@ static char dialogBoxText[512];
 static char *dialogOptText[4];
 static float dialogOptLoc[4][3];
 static unsigned char dialogOptCount = 0;
-static bool dialogPassive = false;
 static bool typeOutDone = true;
 
 extern Menu* currentMenu;
@@ -114,6 +113,8 @@ namespace ui {
        
        bool debug=false;
        bool posFlag=false;
+       bool dialogPassive = false;
+
        
        /*
         *      Dialog stuff that needs to be 'public'.
@@ -555,9 +556,10 @@ namespace ui {
                        
                        if(dialogImportant){
                                setFontColor(255,255,255);
-                               if(fadeIntensity == 255){
+                               if(fadeIntensity == 255 || dialogPassive){
                                        setFontSize(24);
                                        putStringCentered(offset.x,offset.y,rtext);
+                                       setFontSize(16);
                                }
                        }else{
                        
@@ -602,7 +604,7 @@ namespace ui {
                                Mix_PlayChannel(1,dialogClick,0);
                        }
                        
-               }else if(!dialogImportant && !fadeIntensity){
+               }if(!fadeIntensity){
                        vec2 hub = {
                                (SCREEN_WIDTH/2+offset.x)-fontSize*10,
                                (offset.y+SCREEN_HEIGHT/2)-fontSize
@@ -1182,6 +1184,10 @@ DONE:
                                        return;
                                }
                                switch(SDL_KEY){
+                               case SDLK_w:
+                                       dialogPassive = true;
+                                       importantText("Welcome to Meme-Town");
+                                       break;
                                case SDLK_a:
                                        left = false;
                                        break;
index 2012d32fc77735074fbd77ac6671d34e0c99983f..d039bca858e1894c82457c4e4e0cd7298be5e23d 100644 (file)
@@ -17,39 +17,25 @@ bool worldInside = false;           // True if player is inside a structure
 
 WEATHER weather = SUNNY;
 
-// const char *bgPaths[2][7]={
-//     {"assets/bg.png",                               // Daytime background
-//      "assets/bgn.png",                              // Nighttime background
-//      "assets/bgFarMountain.png",            // Furthest layer
-//      "assets/forestTileBack.png",   // Closer layer
-//      "assets/forestTileMid.png",            // Near layer
-//      "assets/forestTileFront.png",  // Closest layer
-//      "assets/dirt.png"},                            // Dirt
-//     {"assets/bgWoodTile.png",
-//      NULL,
-//      NULL,
-//      NULL,
-//      NULL,
-//      NULL}
-// };
-
-const std::string bgPaths[2][8]={
-       {"bg.png",                                      // Daytime background
-        "bgn.png",                                     // Nighttime background
-        "bgFarMountain.png",           // Furthest layer
-        "forestTileBack.png",          // Closer layer
-        "forestTileMid.png",           // Near layer
-        "forestTileFront.png",         // Closest layer
-        "dirt.png",                            // Dirt
-        "grass.png"},                          // Grass
-       {"bgWoodTile.png",
-        "bgWoodTile.png",
-        "bgWoodTile.png",
-        "bgWoodTile.png",
-        "bgWoodTile.png",
-        "bgWoodTile.png",
-        "bgWoodTile.png",
-        "bgWoodTile.png"}
+
+const std::string bgPaths[2][9]={
+                                                                  {"bg.png",                                   // Daytime background
+                                                                       "bgn.png",                                      // Nighttime background
+                                                                       "bgFarMountain.png",            // Furthest layer
+                                                                       "forestTileFar.png",            // Furthest away Tree Layer
+                                                                       "forestTileBack.png",           // Closer layer
+                                                                       "forestTileMid.png",            // Near layer
+                                                                       "forestTileFront.png",          // Closest layer
+                                                                       "dirt.png",                                     // Dirt
+                                                                       "grass.png"},                           // Grass
+                                                                  {"bgWoodTile.png",
+                                                                       "bgWoodTile.png",
+                                                                       "bgWoodTile.png",
+                                                                       "bgWoodTile.png",
+                                                                       "bgWoodTile.png",
+                                                                       "bgWoodTile.png",
+                                                                       "bgWoodTile.png",
+                                                                       "bgWoodTile.png"}
 };
 
 const std::string buildPaths[] = {     "townhall.png",
@@ -61,10 +47,11 @@ const std::string buildPaths[] = {  "townhall.png",
                                                                        "lampPost1.png",
                                                                        "brazzier.png"};
 
-const float bgDraw[3][3]={
+const float bgDraw[4][3]={
        {100,240,.6 },
        {150,250,.4 },
-       {255,255,.25}
+       {200,255,.25},
+       {255,255,.1}
 };
 
 float worldGetYBase(World *w){
@@ -342,7 +329,7 @@ void World::update(Player *p,unsigned int delta){
                if(e->type != STRUCTURET && e->canMove){
                        e->loc.x += e->vel.x * delta;
                        if(e->vel.x < 0)e->left = true;
-          else if(e->vel.x > 0)e->left = false;
+                       else if(e->vel.x > 0)e->left = false;
                }
        }
 
@@ -489,10 +476,10 @@ void World::draw(Player *p){
        glEnd();
        
        /*
-        *      Draw three layers of trees.
+        *      Draw four layers of trees.
        */
 
-       for(i = 0; i < 3; i++){
+       for(i = 0; i < 4; i++){
                bgTex->bindNext();
                safeSetColorA(bgDraw[i][0]-bgshade,bgDraw[i][0]-bgshade,bgDraw[i][0]-bgshade,bgDraw[i][1]);
        
@@ -590,8 +577,7 @@ void World::draw(Player *p){
        }
        for(auto &b : current->build){
                b->draw();
-       }
-       
+       }       
        /*
         *      Draw the layer up until the grass portion, which is done later.
        */
@@ -735,7 +721,6 @@ void World::draw(Player *p){
                        o->loc.y-=(yoff-DRAW_Y_OFFSET);
                }
        }
-
        
        /*
         *      If we're drawing the closest/last world, handle and draw the player.
@@ -955,6 +940,7 @@ void World::singleDetect(Entity *e){
 }
 
 void World::detect(Player *p){
+       //static std::thread villageThread;
        World *hey = this;
        
        /*
@@ -962,6 +948,9 @@ void World::detect(Player *p){
        */
        
        singleDetect(p);
+       //villageLogic(this);
+       //villageThread = std::thread(villageLogic, this);
+
                
        /*
         *      Handle all remaining entities in this world. 
@@ -988,10 +977,38 @@ void World::detect(Player *p){
                }
                what++;
        }what=0;
+       for(auto &b : build){
+               switch(b->bsubtype){
+                       case FOUNTAIN:
+                               for(int r = 0; r < (rand()%25)+10;r++){
+                                       addParticle(    rand()%HLINE*3 + b->loc.x + b->width/2,
+                                                                                               b->loc.y + b->height, 
+                                                                                               HLINE*1.25,
+                                                                                               HLINE*1.25, 
+                                                                                               rand()%2 == 0?-(rand()%7)*.01:(rand()%7)*.01,
+                                                                                               ((4+rand()%6)*.05), 
+                                                                                               {0,0,255}, 
+                                                                                               2500);
+
+                                       particles.back()->fountain = true;
+                               }
+                               break;
+                       case FIRE_PIT:
+                               for(int r = 0; r < (rand()%20)+10;r++){
+                                       addParticle(rand()%(int)(b->width/2) + b->loc.x+b->width/4, b->loc.y+3*HLINE, HLINE, HLINE, rand()%2 == 0?-(rand()%3)*.01:(rand()%3)*.01,((4+rand()%6)*.005), {255,0,0}, 400);
+                                       particles.back()->gravity = false;
+                                       particles.back()->behind = true;
+                               }
+                               break;
+                       default: break;
+               }
+       }
+
        /*if(hey->infront){
                hey = hey->infront;
                goto LOOOOP;
        }*/
+       //villageThread.join();
 }
 void World::addStructure(BUILD_SUB sub, float x,float y, char *tex, const char *inside){
        build.push_back(new Structures());
@@ -1135,7 +1152,7 @@ World *World::goWorldRight(Player *p){
        if(toRight && p->loc.x + p->width > -x_start - HLINE * 15){
                tmp = loadWorldFromXML(toRight);
                
-               p->loc.x = tmp->x_start + HLINE * 10;
+               p->loc.x = tmp->x_start + (int)HLINE * 10;
                p->loc.y = tmp->line[0].y;
                
                return tmp;
@@ -1479,6 +1496,7 @@ extern World *currentWorld;
 World *loadWorldFromXML(const char *path){
        XMLDocument xml;
        XMLElement *wxml;
+       XMLElement *vil;
        
        World *tmp;
        float spawnx;
@@ -1499,11 +1517,17 @@ World *loadWorldFromXML(const char *path){
        
        xml.LoadFile(currentXML);
        wxml = xml.FirstChildElement("World");
+       vil = xml.FirstChildElement("World")->FirstChildElement("village");
 
        if(wxml){
                wxml = wxml->FirstChildElement();
                Indoor = false;
                tmp = new World();
+               if(vil){
+                       vil = vil->FirstChildElement();
+                       //tmp->village.push_back(vil->Attribute("name"));
+
+               }
        }else if((wxml = xml.FirstChildElement("IndoorWorld"))){
                wxml = wxml->FirstChildElement();
                Indoor = true;
@@ -1512,7 +1536,6 @@ World *loadWorldFromXML(const char *path){
        
        while(wxml){
                name = wxml->Name();
-
                if(!strcmp(name,"link")){
                        if((ptr = wxml->Attribute("left")))
                                tmp->setToLeft(ptr);
@@ -1577,9 +1600,26 @@ World *loadWorldFromXML(const char *path){
                        tmp->addMob(MS_TRIGGER,wxml->FloatAttribute("x"),0,commonTriggerFunc);
                        tmp->mob.back()->heyid = wxml->Attribute("id");
                }
-               
+
                wxml = wxml->NextSiblingElement();
        }
+
+       while(vil){
+               name = vil->Name();
+               if(!strcmp(name,"structure")){
+                       ptr = vil->Attribute("inside");
+                       tmp->addStructure((BUILD_SUB)vil->UnsignedAttribute("type"),
+                                                          vil->QueryFloatAttribute("x",&spawnx) != XML_NO_ERROR ? 
+                                                                               getRand() % tmp->getTheWidth() / 2.0f : 
+                                                                               spawnx,
+                                                          100,
+                                                          (char*)vil->Attribute("texture"),
+                                                          ptr);
+
+                       //tmp->village.back().build.push_back(tmp->build.back());
+               }
+               vil = vil->NextSiblingElement();
+       }
        
        std::ifstream dat (((std::string)currentXML + ".dat").c_str());
        if(dat.good()){
index c5e736b960df556e200c785357dc466b29475940..b0fb163e6b841681b44ab1bd2bebea4e023db965 100644 (file)
        <npc name="Ralph" hasDialog="true" />
        <npc name="Johnny" hasDialog="false" />
        <structure type="5" inside="playerSpawnHill1_Building1.xml" />
+       <village name="Meme-Town">
+               <structure type="0" inside="playerSpawnHill1_Building1.xml" />
+               <structure type="5" inside="playerSpawnHill1_Building1.xml" />
+       </village>
 
 </World>
 
@@ -29,14 +33,9 @@ And it wasn't stormy.
                You should go talk to my friend Johnny. He's a pretty chill dude.
        </text>
        
-<<<<<<< HEAD
-       <text id="2" call="Johnny" callid="1">
-               what you have done it to trick Microsoft?
-=======
        <text id="2" >
                Niice.
                <quest check="Your First Quest" fail="3" />
->>>>>>> 3033594b89f23e65b6152daa6610f991307f2f67
        </text>
        
        <text id="3">