]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
Created currency and new inventory
authordrumsetmonkey <abelleisle@roadrunner.com>
Mon, 21 Mar 2016 12:17:06 +0000 (08:17 -0400)
committerdrumsetmonkey <abelleisle@roadrunner.com>
Mon, 21 Mar 2016 12:17:06 +0000 (08:17 -0400)
1  2 
include/ui.h
include/world.h
main.cpp
src/entities.cpp
src/gameplay.cpp
src/inventory.cpp
src/ui.cpp
src/world.cpp

diff --cc include/ui.h
index a4fed3e9a380fbbc3c3f8ba949edb9e692f7d204,072d41887d22824fc09a465409a7d82c06d8032c..2a7518f36ca0670c16b115f68a7ac300bbb9d63d
@@@ -129,9 -126,7 +129,8 @@@ namespace ui 
  
        void setFontFace(const char *ttf);
        void setFontSize(unsigned int size);
 +      void setFontColor(unsigned char r,unsigned char g,unsigned char b, unsigned char a);
  
        /*
         *      Draw a centered string.
        */
        void dialogBox(const char *name,const char *opt,bool passive,const char *text,...);
        void merchantBox(const char *name,Trade trade,const char *opt,bool passive,const char *text,...);
        void merchantBox();
 +      void closeBox();
        void waitForDialog(void);
  
 -
+       void drawPage( std::string path );
        /*
         *      Draws a larger string in the center of the screen. Drawing is done inside this function.
        */
diff --cc include/world.h
Simple merge
diff --cc main.cpp
index 411a8c563bc3a1dd7f64d1e1025ef415341ddecb,69aab76c8f11965c73a62f087237cade38f18508..e7494a98d393659e1beedda730f528e7ddac492f
+++ b/main.cpp
@@@ -415,9 -415,9 +415,8 @@@ int main(int argc, char *argv[])
        //currentWorld->mob.back()->followee = player;
  
        gameRunning = true;
-       while(gameRunning){
 -      
 -      while ( gameRunning )
--              mainLoop();
-       }
++
++      while(gameRunning)mainLoop();
  
        /**************************
        ****   CLOSE PROGRAM   ****
@@@ -492,15 -492,7 +491,14 @@@ void mainLoop(void)
                prevPrevTime = currentTime;
        }
  
-       currentWorld->update(player,deltaTime);
 +      /*
 +       * Update player and entity coordinates.
 +       */
 +
 +      /*pool.Enqueue([](){
 +              currentWorld->update(player,deltaTime);
 +      });*/
+       currentWorld->update( player, deltaTime );
  
        /*
         * Update debug variables if necessary
@@@ -789,8 -781,8 +787,7 @@@ void logic()
                                        for(int r = 0; r < (rand()%30)+15;r++)
                                                currentWorld->addParticle(rand()%HLINE*3 + n->loc.x - .05f,n->loc.y + n->height*.5, HLINE,HLINE, -(rand()%10)*.01,((rand()%10)*.01-.05), {(rand()%75)+10/100.0f,0,0}, 10000);
                                }
 -                      }*/
 -
 +                      }
                        /*
                         *      Don't bother handling the NPC if another has already been handled.
                         */
Simple merge
Simple merge
Simple merge
diff --cc src/ui.cpp
index 3b3f2984fdf96852c94b1c5d88c7e5cf17a37434,f69bfe812984931fcaca7e53120e4e41b0714a3f..245f1d7208190703d2b8e95017105156d4c77a25
@@@ -124,9 -126,7 +126,8 @@@ namespace ui 
        int dialogPassiveTime = 0;
        Trade merchTrade;
  
 +      int fontTransInv = 255;
  
        /*
         *      Dialog stuff that needs to be 'public'.
        */
                 *      Loop on each character:
                */
  
 -              do {
 +              do{
                        if(i && ((i / 110.0) == (i / 110))){
-                               yo-=fontSize*1.05;
-                               xo=x;
+                               o.y -= fontSize * 1.05f;
+                               o.x = x;
                                if(s[i] == ' ')
                                        i++;
                        }
                unsigned int i = 0;
                float width = 0;
  
-               do{
-                       if(s[i]=='\n'){                 //      Handle newlines
+               do {
+                       switch ( s[i] ) {
+                       case '\n':
                                // TODO
-                       }else if(s[i]==' '){    //      Handle spaces
-                               width+=fontSize/2;
-                       }else if(s[i]=='\b'){   //      Handle backspaces?
-                               // Why?
-                               // Cuz
-                       }else{
-                               width+=ftexwh[i].x+fontSize*.1;
+                               break;
+                       case '\b':
+                               break;
+                       case ' ':
+                               width += fontSize / 2;
+                               break;
+                       default:
+                               width += ftexwh[i].x + fontSize * 0.1f;
+                               break;
                        }
-               }while(s[++i]);
+               } while(s[++i]);
 -
                putString(floor(x-width/2),y,s);
                return width;
        }
                fclose(bmp);
        }
  
 +      void closeBox(){
 +              dialogBoxExists = false;
 +              dialogMerchant = false;
 +      }
 +
        void dialogAdvance(void){
                unsigned char i;
+               if ( pageTex ) {
+                       glDeleteTextures( 1, &pageTex );
+                       pageTex = 0;
+                       return;
+               }
                if(!typeOutDone){
                        typeOutDone = true;
                        return;
diff --cc src/world.cpp
index c31f551a8a8e412f56f13cf77e37fad6a01b23be,dec9a64e849b654991bb30c244fa5933e0cc0e6f..b1eb12e0a2d5e91dd440cf8114c59cb270a27cdd
@@@ -220,10 -218,7 +218,6 @@@ World:
                Mix_FreeMusic(bgmObj);
  
        delete bgTex;
-       delete[] toLeft;
-       delete[] toRight;
--
        deleteEntities();
  }
  
@@@ -772,16 -772,22 +771,21 @@@ singleDetect( Entity *e 
  
                if ( e->loc.y < worldData[i].groundHeight ) {
  
-                       e->loc.y= worldData[i].groundHeight - .001 * deltaTime;
-                       e->ground=true;
-                       e->vel.y=0;
 -      if ( worldData[i].groundHeight - e->loc.y > 30 ) {
 -        int dir = e->vel.x > 0 ? -1 : 1;
 -        e->loc.x += HLINE * 8 * dir;
 -        e->loc.y = worldData[i + 8 * dir].groundHeight;
 -      } else {
 -        e->loc.y = worldData[i].groundHeight - .001 * deltaTime;
 -                        e->ground = true;
 -                        e->vel.y = 0;
 -      }
++            if ( worldData[i].groundHeight - e->loc.y > 30 ) {
++                int dir = e->vel.x > 0 ? -1 : 1;
++                e->loc.x += HLINE * 8 * dir;
++                e->loc.y = worldData[i + 8 * dir].groundHeight;
++            } else {
++                e->loc.y = worldData[i].groundHeight - .001 * deltaTime;
++                e->ground = true;
++                e->vel.y = 0;
++            }
  
                /*
                 *      Handle gravity if the entity is above the line.
                */
  
 -              } else {
 -
 +              }else{
                        if(e->type == STRUCTURET && e->loc.y > 2000){
                                e->loc.y = worldData[i].groundHeight;
                                e->vel.y = 0;
@@@ -969,26 -976,18 +974,19 @@@ void World::addLight(vec2 loc, Color co
        }
  }
  
- char *World::setToLeft(const char *file){
-       if(toLeft)
-               delete[] toLeft;
-       if(!file)
-               return (toLeft = NULL);
-       strcpy((toLeft = new char[strlen(file) + 1]),file);
-       return toLeft;
+ std::string World::
+ setToLeft( std::string file )
+ {
+     return (toLeft = file);
  }
- char *World::setToRight(const char *file){
-       if(toRight)
-               delete[] toRight;
-       if(!file)
-               return (toRight = NULL);
-       strcpy((toRight = new char[strlen(file) + 1]),file);
-       return toRight;
+ std::string World::
+ setToRight( std::string file )
+ {
+       return (toRight = file);
  }
  
 +//what is this clyne why are they differnet
  World *World::
  goWorldLeft( Player *p )
  {
@@@ -1107,14 -1133,10 +1132,12 @@@ void World::save(void)
                data.append(std::to_string((int)m->alive) + "\n");
        }
  
-     std::cout << "Ending file" << std::endl;
        data.append("dOnE\0");
 +    std::cout << "Writing to the file" << std::endl;
        out.write(data.c_str(),data.size());
  
-     std::cout << "Closing file" << std::endl;
        out.close();
 +    std::cout << "Done saving" << std::endl;
  }
  
  void World::load(void){