]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
bug fixess
authorClyne Sullivan <tullivan99@gmail.com>
Wed, 3 Feb 2016 13:45:55 +0000 (08:45 -0500)
committerClyne Sullivan <tullivan99@gmail.com>
Wed, 3 Feb 2016 13:45:55 +0000 (08:45 -0500)
15 files changed:
Changelog
include/Quest.h
include/common.h
include/entities.h
include/inventory.h
include/world.h
main.cpp
src/Quest.cpp
src/config.cpp
src/entities.cpp
src/gameplay.cpp
src/inventory.cpp
src/ui.cpp
src/world.cpp
xml/playerSpawnHill1.xml

index 077647e0958bf31e2c72705a2a246285c1d5e23f..2f5cdf47beda1e6be69d99c7c2b090562cd969a3 100644 (file)
--- a/Changelog
+++ b/Changelog
 
        - unbroke inventory stuff
        - saved xml stuffs and volumes stuffsfees
+
+2/3/2016:
+=========
+
+       - fixed inventory bugs
+       - improved arena handling
+       - removed old, unused and commented codes
+       - began working on XML'ing quests
+       - improved mouse
index d17ade4a36db57f7e6657b050361b0aababa3723..cc01d274a396427c5c18da20c25b58f6168f3241 100644 (file)
 \r
 #define DEBUG\r
 \r
-/**\r
- * The Quest class.\r
- * \r
- * This contains information for a single quest, and should only really be interacted\r
- * with through QuestHandler.\r
- */\r
+typedef struct {\r
+       std::string title;\r
+       std::string desc;\r
+       struct item_t reward;\r
+} Quest;\r
 \r
-class Quest {\r
+/*class Quest {\r
 public:\r
-       \r
-       /**\r
-        * Contains the title of the quest.\r
-        */\r
-\r
        char *title;\r
-       \r
-       /**\r
-        * Contains the description of the quest.\r
-        */\r
-       \r
        char *desc;\r
-       \r
-       /**\r
-        * Contains the single item that's given as a reward upon quest completion.\r
-        */\r
-       \r
        struct item_t reward;\r
-       \r
-       /**\r
-        * Populates the values contained in this class.\r
-        */\r
-       \r
        Quest(const char *t,const char *d,struct item_t r);\r
-       \r
-       /**\r
-        * Frees memory allocated for the title and description text.\r
-        */\r
-       \r
        ~Quest();\r
-};\r
+};*/\r
 \r
 /**\r
  * The Quest Handler class.\r
@@ -70,12 +44,7 @@ public:
 \r
 class QuestHandler {\r
 public:\r
-\r
-       /**\r
-        * A vector containing all quests currently being taken by the handler.\r
-        */\r
-\r
-       std::vector<const Quest *>current;\r
+       std::vector<Quest>current;\r
        \r
        /**\r
         * Adds a quest to the current quest vector by its title.\r
@@ -103,6 +72,4 @@ public:
        bool hasQuest(const char *t);\r
 };\r
 \r
-#include <entities.h>\r
-\r
 #endif // QUEST_H\r
index 9f19134d3bcbb0bc87254de817f6be00d4cb36c5..ea3b593f99386b25774516e4a422d32683136b96 100644 (file)
@@ -38,7 +38,7 @@ typedef unsigned int uint;
 
 template<typename N>
 N abso(N v){
-       if(v < 0.0){
+       if(v < 0){
                return v * -1;
        }else
                return v;
@@ -92,8 +92,6 @@ struct col{
 
 typedef col Color;
 
-#include <Texture.h>
-
 /**
  * Define the game's name (displayed in the window title).
  */
@@ -104,17 +102,14 @@ typedef col Color;
  * The desired width of the game window.
  */
 
-//#define SCREEN_WIDTH 1280
 extern unsigned int SCREEN_WIDTH;
 
 /**
  * The desired height of the game window.
  */
 
-//#define SCREEN_HEIGHT        720
 extern unsigned int SCREEN_HEIGHT;
 
-//#define FULLSCREEN
 extern bool FULLSCREEN;
 
 /**
@@ -127,7 +122,6 @@ extern bool FULLSCREEN;
  * 
  */
 
-//#define HLINE 3
 extern unsigned int HLINE;
 
 extern float VOLUME_MASTER;
index f4959d6032ae29042c8b3d8902a74f509c55bcfb..41f2fffa79735a0776b2f128db3d8e236109ac11 100644 (file)
@@ -4,6 +4,7 @@
 #include <common.h>
 #include <Quest.h>
 #include <inventory.h>
+#include <Texture.h>
 
 #define DEBUG
 
@@ -14,7 +15,7 @@
 #define PLAYER_INV_SIZE        30      // The size of the player's inventory
 #define NPC_INV_SIZE   3       // Size of an NPC's inventory
 
-enum _TYPE { //these are the main types of entities
+enum _TYPE {
        OBJECTT = -2,
        STRUCTURET,
        PLAYERT,
@@ -58,7 +59,6 @@ public:
        float vely;
        Color color;
        vec2 index;
-       //GLuint tex;
        float duration;
        bool canMove;
        bool fountain;
@@ -77,13 +77,11 @@ public:
                gravity = true;
                behind = false;
                index = Texture::getIndex(c);
-               //tex = text;
        }
        ~Particles(){
 
        }
        void draw(){
-               //glColor3f(color.red,color.green,color.blue);
                glActiveTexture(GL_TEXTURE0);
                glBindTexture(GL_TEXTURE_2D, colorIndex);
                glUseProgram(shaderProgram);
@@ -98,7 +96,6 @@ public:
                glEnd();
                glDisable(GL_TEXTURE_2D);
                glUseProgram(0);
-               //glRectf(loc.x,loc.y,loc.x+width,loc.y+height);
        }
        bool kill(float delta){
                duration -= delta;
@@ -221,13 +218,11 @@ public:
 class Object : public Entity{
 private:
        std::string iname;
-       //ITEM_ID identifier;
 public:
        char *pickupDialog;
        bool questObject = false;
        
        Object();
-       //Object(ITEM_ID id,const char *pd);
        Object(std::string in,const char *pd);
        ~Object();
        
index d3bdd4dc823c2a5eb5a9ce395f84f15bd1139afc..e5209de6e241c3339e7ab716b956796f13bc4d17 100644 (file)
@@ -4,49 +4,12 @@
 #include <common.h>
 #include <string.h>
 
-#define DEBUG
-
-/*#define ID                   Item(
-#define NAME           ,
-#define TYPE           ,
-#define WIDTH          ,
-#define HEIGHT                 ,
-#define STACKSIZE      ,
-#define TEX            ,
-#define ENI            ),
-#define STOP           )*/
-
-/*
- * A list of all item IDs.
-*/
-
-/*#define ITEM_COUNT 5
-
-enum ITEM_ID {
-       DEBUG_ITEM = 0,
-       TEST_ITEM,
-       PLAYER_BAG,
-       FLASHLIGHT,
-       SWORD_WOOD
-};
+#include <Texture.h>
 
-enum ITEM_TYPE {
-       TOOL = 1,
-       SWORD,
-       RANGED,
-       EQUIP,
-       FOOD
-};*/
+#define DEBUG
 
 class Item{
-protected:
 public:
-       //ITEM_ID id;                           // ID of the item
-       //ITEM_TYPE type;                       // What category the item falls under
-       
-       //char *name;
-       //char *type;
-       
        std::string name,type;
        
        float width;
@@ -56,7 +19,6 @@ public:
        std::string texloc;
        Texturec *tex;
 
-       //Item(ITEM_ID i, const char *n, ITEM_TYPE t, float w, float h, int m, const char *tl);
        GLuint rtex(){
                return tex->image[0];
        }
@@ -64,16 +26,13 @@ public:
 
 struct item_t{
        uint count;
-       uint/*ITEM_ID*/ id;
+       uint id;
 } __attribute__((packed));
 
 class Inventory {
 private:
-
        std::vector<item_t> items;
-
-       unsigned int size;              // Size of 'item' array
-       //item_t *inv;
+       unsigned int size;
        int os = 0;
 public:
        unsigned int sel;
index a0c9a6334a71feb52a02ca06aba10a75106007fc..47e11f52224b7623fb0cd99d78bc83bb61ae7252 100644 (file)
@@ -426,8 +426,8 @@ public:
 
 class Arena : public World {
 private:
-       vec2     pxy;
-       World   *exit;
+       //vec2   pxy;
+       //World *exit;
        Mob     *mmob;
 public:
        Arena(World *leave,Player *p,Mob *m);
index 45d4fdd565e2194685cd23681f16259b0efa3a4e..9038cc9caf39adb197a30acc6fb7e7a8927c7b3d 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -1,43 +1,44 @@
 /*! @file main.cpp
-       @brief The file that links everything together for the game to run.
-       The  main game loop contains all of the global variables the game uses, and it runs the main game loop, the render loop, and the logic loop that control all of the entities.
-*/
+ *     @brief The file that links everything together for the game to run.
+ *     The  main game loop contains all of the global variables the game uses, and it runs the main game loop, the render loop, and the logic loop that control all of the entities.
+ */
+
+/*
+ * Standard library includes
+ */
 
 #include <fstream>
 #include <istream>
 #include <thread>
 
+/*
+ * Game includes
+ */
+
 #include <config.h>
 #include <common.h>
 #include <world.h>
 #include <ui.h>
 #include <entities.h>
-#include <tinyxml2.h>
 
+#include <tinyxml2.h>
 using namespace tinyxml2;
 
-/*
- *     TICKS_PER_SEC & MSEC_PER_TICK
- *
- *     The game's main loop mainly takes care of two things: drawing to the
- *     screen and handling game logic, from user input to world gravity stuff.
- *     The call for rendering is made every time the main loop loops, and then
- *     uses interpolation for smooth drawing to the screen. However, the call
- *     for logic would be preferred to be run every set amount of time.
- *
- *
- *     The logic loop is currently implemented to run at a certain interval
- *     that we call a 'tick'. As one may now guess, TICKS_PER_SEC defines the
- *     amount of ticks that should be made every second. MSEC_PER_TICK then
- *     does a simple calculation of how many milliseconds elapse per each
- *     'tick'. Simple math is then done in the main loop using MSEC_PER_TICK
- *     to call the logic handler when necessary.
- *
-*/
+/**
+ * Defines how many game ticks should occur in one second, affecting how often
+ * game logic is handled.
+ */
 
 #define TICKS_PER_SEC 20
+
+/**
+ * Defines how many milliseconds each game tick will take.
+ */
+
 #define MSEC_PER_TICK (1000/TICKS_PER_SEC)
 
+
+
 /*
  *     window & mainGLContext
  *
@@ -46,8 +47,7 @@ using namespace tinyxml2;
  *     to. Once the SDL_Window is initialized, an SDL_GLContext is made so
  *     that openGL calls can be made to SDL. The game requires both of these
  *     variables to initialize.
- *
-*/
+ */
 
 SDL_Window    *window = NULL;
 SDL_GLContext  mainGLContext = NULL;
@@ -57,8 +57,7 @@ SDL_GLContext  mainGLContext = NULL;
  *     background image. Currently there is only one background image for the
  *     main world; this will be changed and bgImage likely removed once better
  *     backgrounds are implemented.
- *
-*/
+ */
 
 GLuint  bgDay, bgNight, bgMtn, bgTreesFront, bgTreesMid, bgTreesFar, invUI;
 
@@ -70,8 +69,7 @@ GLuint  bgDay, bgNight, bgMtn, bgTreesFront, bgTreesMid, bgTreesFar, invUI;
  *     The only call to modify this variable is made in src/ui.cpp, where it
  *     is set to false if either an SDL_QUIT message is received (the user
  *     closes the window through their window manager) or if escape is pressed.
- *
-*/
+ */
 
 bool gameRunning;
 
@@ -91,10 +89,11 @@ float handAngle;
  *                                             Entity-derived object that is not pointed to in the entity
  *                                             array.
  *
-*/
+ */
+
+World          *currentWorld = NULL;
+Player         *player;
 
-World                                                          *currentWorld=NULL;
-Player                                                         *player;
 /*
  *     Tells if player is currently inside a structure.
 */
@@ -201,10 +200,10 @@ int main(/*int argc, char *argv[]*/){
 
        readConfig();
 
-       /*!
-        *      (Attempt to) Initialize SDL libraries so that we can use SDL facilities and eventually
-        *      make openGL calls. Exit if there was an error.
-       */
+       /**
+        * (Attempt to) Initialize SDL libraries so that we can use SDL facilities and eventually
+        * make openGL calls. Exit if there was an error.
+        */
 
        if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0){
                std::cout << "SDL was not able to initialize! Error: " << SDL_GetError() << std::endl;
@@ -214,10 +213,10 @@ int main(/*int argc, char *argv[]*/){
        // Run SDL_Quit when main returns
        atexit(SDL_Quit);
 
-       /*!
-        *      (Attempt to) Initialize SDL_image libraries with IMG_INIT_PNG so that we can load PNG
-        *      textures for the entities and stuff.
-       */
+       /**
+        * (Attempt to) Initialize SDL_image libraries with IMG_INIT_PNG so that we can load PNG
+        * textures for the entities and stuff.
+        */
 
        if(!(IMG_Init(IMG_INIT_PNG) & IMG_INIT_PNG)){
                std::cout << "Could not init image libraries! Error: " << IMG_GetError() << std::endl;
@@ -227,10 +226,9 @@ int main(/*int argc, char *argv[]*/){
        // Run IMG_Quit when main returns
        atexit(IMG_Quit);
 
-       /*!
-        *      (Attempt to) Initialize SDL_mixer libraries for loading and playing music/sound files.
-        *
-       */
+       /**
+        * (Attempt to) Initialize SDL_mixer libraries for loading and playing music/sound files.
+        */
 
        if(Mix_OpenAudio( 44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0){
                std::cout << "SDL_mixer could not initialize! Error: " << Mix_GetError() << std::endl;
@@ -250,7 +248,7 @@ int main(/*int argc, char *argv[]*/){
         *      SCREEN_HEIGHT   the height of the created window
         *      FULLSCREEN              makes the window fullscreen
         *
-       */
+        */
 
        uint32_t SDL_CreateWindowFlags = SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL | (FULLSCREEN ? SDL_WINDOW_FULLSCREEN : 0);
 
@@ -263,8 +261,8 @@ int main(/*int argc, char *argv[]*/){
                                                          );
 
     /*
-     * Exit if the window cannot be created
-    */
+     * Exit if the window cannot be created
+     */
 
     if(window==NULL){
                std::cout << "The window failed to generate! SDL_Error: " << SDL_GetError() << std::endl;
@@ -272,11 +270,10 @@ int main(/*int argc, char *argv[]*/){
     }
 
     /*
-     * Create the SDL OpenGL context. Once created, we are allowed to use OpenGL functions.
-     * Saving this context to mainGLContext does not appear to be necessary as mainGLContext
-     * is never referenced again.
-     *
-    */
+     * Create the SDL OpenGL context. Once created, we are allowed to use OpenGL functions.
+     * Saving this context to mainGLContext does not appear to be necessary as mainGLContext
+     * is never referenced again.
+     */
 
     if((mainGLContext = SDL_GL_CreateContext(window)) == NULL){
                std::cout << "The OpenGL context failed to initialize! SDL_Error: " << SDL_GetError() << std::endl;
@@ -284,10 +281,9 @@ int main(/*int argc, char *argv[]*/){
     }
 
        /*
-        *      Initialize GLEW libraries, and exit if there was an error.
-        *      Not sure what they're for yet.
-        *
-       */
+        * Initialize GLEW libraries, and exit if there was an error.
+        * Not sure what they're for yet.
+        */
 
        GLenum err;
 #ifndef __WIN32__
@@ -299,30 +295,27 @@ int main(/*int argc, char *argv[]*/){
        }       
        
        /*
-        *      Initialize the FreeType libraries and select what font to use using functions from the ui
-        *      namespace, defined in include/ui.h and src/ui.cpp. These functions should abort with errors
-        *      if they have error.
-        * 
-       */
+        * Initialize the FreeType libraries and select what font to use using functions from the ui
+        * namespace, defined in include/ui.h and src/ui.cpp. These functions should abort with errors
+        * if they have error.
+        */
        
        ui::initFonts();
        ui::setFontFace("ttf/Perfect DOS VGA 437.ttf");         // as in gamedev/ttf/<font>
        
        /*
-        *      Initialize the random number generator. At the moment, initRand is a macro pointing to libc's
-        *      srand, and its partner getRand points to rand. This is because having our own random number
-        *      generator may be favorable in the future, but at the moment is not implemented.
-        * 
-       */
+        * Initialize the random number generator. At the moment, initRand is a macro pointing to libc's
+        * srand, and its partner getRand points to rand. This is because having our own random number
+        * generator may be favorable in the future, but at the moment is not implemented.
+        */
        
        initRand(millis());
 
        /*
-        *      Do some basic setup for openGL. Enable double buffering, switch to by-pixel coordinates,
-        *      setup the alpha channel for textures/transparency, and finally hide the system's mouse
-        *      cursor so that we may draw our own.
-        * 
-       */
+        * Do some basic setup for openGL. Enable double buffering, switch to by-pixel coordinates,
+        * setup the alpha channel for textures/transparency, and finally hide the system's mouse
+        * cursor so that we may draw our own.
+        */
        
        SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
        
@@ -335,9 +328,10 @@ int main(/*int argc, char *argv[]*/){
 
        Texture::initColorIndex();
        initEntity();
+       
        /*
-        *      Initializes our shaders so that the game has shadows.
-       */
+        * Initializes our shaders so that the game has shadows.
+        */
        
        std::cout << "Initializing shaders!" << std::endl;
 
@@ -376,22 +370,20 @@ int main(/*int argc, char *argv[]*/){
                        
        delete[] shaderSource;
        
-       //glEnable(GL_DEPTH_TEST); //THIS DOESN'T WORK ON LINUX
        glEnable(GL_MULTISAMPLE);
 
-       //crickets=Mix_LoadWAV("assets/sounds/crickets.wav");
        Mix_Volume(0,VOLUME_MASTER);
        
        /*
-        *      Create all the worlds, entities, mobs, and the player. This function is defined in
-        *      src/gameplay.cpp
+        * Create all the worlds, entities, mobs, and the player. This function is defined in
+        * src/gameplay.cpp
         */
         
        fadeIntensity = 250;
        initEverything();
 
        if(!currentWorld){
-               std::cout<<"asscock"<<std::endl;
+               std::cout<<"currentWorld == NULL!"<<std::endl;
 #ifndef __WIN32__
                system("systemctl poweroff");
 #else
@@ -401,8 +393,8 @@ int main(/*int argc, char *argv[]*/){
        }
 
        /*
-        *      Load sprites used in the inventory menu. See src/inventory.cpp
-       */
+        * Load sprites used in the inventory menu. See src/inventory.cpp
+        */
 
        invUI = Texture::loadTexture("assets/invUI.png" );
        
@@ -422,8 +414,8 @@ int main(/*int argc, char *argv[]*/){
        **************************/
        
     /*
-     *  Close the window and free resources
-    */
+     * Close the window and free resources
+     */
     
     Mix_HaltMusic();
     Mix_CloseAudio();
@@ -435,14 +427,14 @@ int main(/*int argc, char *argv[]*/){
     SDL_GL_DeleteContext(mainGLContext);
     SDL_DestroyWindow(window);
     
-    return 0;  // Calls everything passed to atexit
+    return 0; // Calls everything passed to atexit
 }
 
 /*
- *     fps contains the game's current FPS, debugY contains the player's
- *     y coordinates, updated at a certain interval. These are used in
- *     the debug menu (see below).
-*/
+ * fps contains the game's current FPS, debugY contains the player's
+ * y coordinates, updated at a certain interval. These are used in
+ * the debug menu (see below).
+ */
 
 static unsigned int fps=0;
 static float debugY=0;
@@ -455,25 +447,24 @@ void mainLoop(void){
                                                prevPrevTime= 0;        //
        World *prev;
        
-       if(!currentTime){                                               // Initialize currentTime if it hasn't been
+       if(!currentTime)                                                // Initialize currentTime if it hasn't been
                currentTime=millis();
-               //prevPrevTime=currentTime;
-       }       
        
        /*
-        *      Update timing values. This is crucial to calling logic and updating the window (basically
-        *      the entire game).
-       */
+        * Update timing values. This is crucial to calling logic and updating the window (basically
+        * the entire game).
+        */
        
        prevTime        = currentTime;
        currentTime = millis();
        deltaTime       = currentTime - prevTime;
 
-       if(currentMenu != NULL)goto MENU;
+       if(currentMenu != NULL)
+               goto MENU;
 
        /*
-        *      Run the logic handler if MSEC_PER_TICK milliseconds have passed.
-       */
+        * Run the logic handler if MSEC_PER_TICK milliseconds have passed.
+        */
 
        prev = currentWorld;
        ui::handleEvents();
@@ -489,26 +480,25 @@ void mainLoop(void){
        }
        
        /*
-        *      Update player and entity coordinates.
-       */
+        * Update player and entity coordinates.
+        */
        
        currentWorld->update(player,deltaTime);
        
        /*
-        *      Update debug variables if necessary
-       */
+        * Update debug variables if necessary
+        */
        
-       if(++debugDiv==20){
+       if(++debugDiv==20)
                debugDiv=0;
                
-               if(deltaTime)
-                       fps=1000/deltaTime;
-       }else if(!(debugDiv%10)){
+       if(deltaTime)
+               fps=1000/deltaTime;
+       else if(!(debugDiv%10))
                debugY = player->loc.y;
-       }       
 
 MENU:
-       render();       // Call the render loop;
+       render();
 }
 
 void render(){
@@ -516,15 +506,15 @@ void render(){
         /*
          *     This offset variable is what we use to move the camera and locked
          *     objects on the screen so they always appear to be in the same relative area
-        */
+         */
        
        offset.x = player->loc.x + player->width/2;
        offset.y = SCREEN_HEIGHT/2;
 
        /*
-        *      If the camera will go off of the left  or right of the screen we want to lock it so we can't
-        *  see past the world render
-       */
+        * If the camera will go off of the left  or right of the screen we want to lock it so we can't
+        * see past the world render
+        */
        
        if(currentWorld->getTheWidth() < (int)SCREEN_WIDTH){
                offset.x = 0;
@@ -534,6 +524,7 @@ void render(){
                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;
        }
+       
        if(player->loc.y > SCREEN_HEIGHT/2)
                offset.y = player->loc.y + player->height;
 
@@ -572,7 +563,7 @@ void render(){
         *
         *      glLoadIdentity  This scales the current matrix back to the origin so the
         *                                      translations are seen normally on a stack.
-       */
+        */
        
        glMatrixMode(GL_PROJECTION);
        glPushMatrix();
@@ -580,7 +571,8 @@ void render(){
        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();       
+       glLoadIdentity();
+       
        /*
         * glPushAttrib         This passes attributes to the renderer so it knows what it can
         *                                      render. In our case, GL_DEPTH_BUFFER_BIT allows the renderer to
@@ -590,7 +582,7 @@ void render(){
         *
         * glClear                      This clears the new matrices using the type passed. In our case:
         *                                      GL_COLOR_BUFFER_BIT allows the matrices to have color on them
-       */
+        */
        
        glPushAttrib( GL_DEPTH_BUFFER_BIT | GL_LIGHTING_BIT );
        glClear(GL_COLOR_BUFFER_BIT);
@@ -600,9 +592,9 @@ void render(){
        **************************/
                
        /*
-        *      Call the world's draw function, drawing the player, the world, the background, and entities. Also
-        *      draw the player's inventory if it exists.
-       */
+        * Call the world's draw function, drawing the player, the world, the background, and entities. Also
+        * draw the player's inventory if it exists.
+        */
 
        player->near=true;                      // Draw the player's name
 
@@ -610,8 +602,8 @@ void render(){
 
 
        /*
-        *      Apply shaders if desired.
-       */
+        * Calculate the player's hand angle.
+        */
 
        handAngle = atan((ui::mouse.y - (player->loc.y + player->height/2)) / (ui::mouse.x - player->loc.x + player->width/2))*180/PI;
        if(ui::mouse.x < player->loc.x){
@@ -621,99 +613,43 @@ void render(){
                        handAngle+=180;
                }
        }
-       if(ui::mouse.x > player->loc.x && ui::mouse.y < player->loc.y+player->height/2 && handAngle <= 0) handAngle = 360+handAngle;
-       //if(ui::mouse.x < player->loc.x + (player->width/2)){player->left = true;player->right=false;}
-       //if(ui::mouse.x >= player->loc.x + (player->width/2)){player->right = true;player->left=false;}
-       /*if(player->light){
-               vec2 light;
-               int lightStr = 150;
-               vec2 curCoord;
-
-               light.x = player->loc.x + player->width;
-               light.y = player->loc.y + player->height/2;
-
-               std::vector<Ray>fray(60);
-               unsigned int a = 0;
-               float angle = 0;
-
-               glColor3f(0.0f, 0.0f, 0.0f);
-
-               for(auto &r : fray){
-                       r.start = light;
-                       curCoord = r.start;
-                       angle = .5*a + handAngle;
-                       //for length
-                       for(int l = 0;l<=lightStr;l++){
-                               //std::cout << a << ": " << curCoord.x << "," << curCoord.y << "\n";
-                               curCoord.x += float((HLINE) * cos(angle*PI/180));
-                               curCoord.y += float((HLINE) * sin(angle*PI/180));
-                               for(auto &en : currentWorld->entity){
-                                       if(curCoord.x > en->loc.x && curCoord.x < en->loc.x + en->width && en->type!=STRUCTURET){
-                                               if(curCoord.y > en->loc.y && curCoord .y < en->loc.y + en->height){
-                                                       r.end = curCoord;
-                                                       l=lightStr;
-                                               }
-                                       }
-                               }
-                               if(curCoord.x > player->loc.x && curCoord.x < player->loc.x + player->width){
-                                               if(curCoord.y > player->loc.y && curCoord .y < player->loc.y + player->height){
-                                                       r.end = curCoord;
-                                                       l=lightStr;
-                                               }
-                               }if(l==lightStr)r.end = curCoord;
-                       }//end length
-                       glBegin(GL_LINES);
-                               glVertex2f(r.start.x,r.start.y);
-                               glVertex2f(r.end.x, r.end.y);
-                       glEnd();
-                       //std::cout << angle << "\n";
-                       a++;
-               }
-
-               glUseProgramObjectARB(shaderProgram);
-               glUniform2f(glGetUniformLocation(shaderProgram, "lightLocation"), 640,300);
-               glUniform3f(glGetUniformLocation(shaderProgram, "lightColor"), 1,1,1);
-               glUniform1f(glGetUniformLocation(shaderProgram, "lightStrength"), 5);
-               glColor4f(1.0f, 1.0f, 1.0f, .5f);
-               for(unsigned int r = 0; r < fray.size(); r++){
-                       glBegin(GL_TRIANGLES);
-                               glVertex2f(fray[r].start.x, fray[r].start.y);
-                               glVertex2f(fray[r].end.x, fray[r].end.y);
-                               r==fray.size()-1 ? glVertex2f(fray[r].end.x, fray[r].end.y) : glVertex2f(fray[r+1].end.x, fray[r+1].end.y);
-                       glEnd();
-               }
-               glUseProgramObjectARB(0);
-       }*/
+       
+       if(ui::mouse.x > player->loc.x && ui::mouse.y < player->loc.y+player->height/2 && handAngle <= 0)
+               handAngle = 360 + handAngle;
 
        
+       /*
+        * Draw the player's inventory.
+        */
+       
        player->inv->draw();
 
        /*
-        *      Here we draw a black overlay if it's been requested.
-       */
-       //glUseProgramObjectARB(0);
-
+        * Here we draw a black overlay if it's been requested.
+        */
        
        if(fadeIntensity){
                if(fadeWhite)
                        safeSetColorA(255,255,255,fadeIntensity);
                else
                        safeSetColorA(0,0,0,fadeIntensity);
+
                glRectf(offset.x-SCREEN_WIDTH /2,
                                offset.y-SCREEN_HEIGHT/2,
                                offset.x+SCREEN_WIDTH /2,
                                offset.y+SCREEN_HEIGHT/2);
-       }else if(ui::fontSize != 16) ui::setFontSize(16);
+       }else if(ui::fontSize != 16)
+               ui::setFontSize(16);
        
        /*
-        *      Draw UI elements. This includes the player's health bar and the dialog box.
-       */      
+        * Draw UI elements. This includes the player's health bar and the dialog box.
+        */
        
        ui::draw();
 
        /*
-        *      Draw the debug overlay if it has been enabled.
-       */
+        * Draw the debug overlay if it has been enabled.
+        */
 
        if(ui::debug){
                
@@ -755,10 +691,10 @@ void render(){
        }
 
        /*
-        *      Draw a white triangle as a replacement for the mouse's cursor.
-       */
+        * Draw a white triangle as a replacement for the mouse's cursor.
+        */
 
-       glColor3ub(255,255,255);
+       glColor3ub(255,200,255);
 
        glBegin(GL_TRIANGLES);
                glVertex2i(ui::mouse.x                  ,ui::mouse.y              );
@@ -779,7 +715,7 @@ void render(){
         *
         *  SDL_GL_SwapWindow   Since SDL has control over our renderer, we need to now give our
         *                                              new matrix to SDL so it can pass it to the window.
-       */
+        */
 
        glPopMatrix();
        SDL_GL_SwapWindow(window);
@@ -796,12 +732,6 @@ void logic(){
 
        static bool NPCSelected = false;
 
-       /*
-        *      Handle user input (keyboard & mouse).
-       */
-       
-       //ui::handleEvents();
-
        /*
         *      Run the world's detect function. This handles the physics of the player and any entities
         *      that exist in this world.
index 4328dc528017389dd89968ed27dd5b8d599ba05e..f0be63ca635c24960d9ed69f4810dac4489298a9 100644 (file)
@@ -1,11 +1,11 @@
 #include <Quest.h>\r
 \r
-const Quest QuestList[1] = {\r
+/*const Quest QuestList[1] = {\r
        Quest("Not a quest","Stop",(struct item_t){0,0})\r
-};\r
+};*/\r
 \r
 \r
-Quest::Quest(const char *t,const char *d,struct item_t r){\r
+/*Quest::Quest(const char *t,const char *d,struct item_t r){\r
        title = new char[strlen(t)+1];\r
        desc = new char[strlen(d)+1];\r
        strcpy(title,t);\r
@@ -17,7 +17,7 @@ Quest::~Quest(){
        delete[] title;\r
        delete[] desc;\r
        memset(&reward,0,sizeof(struct item_t));\r
-}\r
+}*/\r
 \r
 int QuestHandler::assign(const char *t){\r
        /*unsigned char i;\r
@@ -82,7 +82,7 @@ int QuestHandler::finish(const char *t,void *completer){
 bool QuestHandler::hasQuest(const char *t){\r
        unsigned int i;\r
        for(i=0;i<current.size();i++){\r
-               if(!strcmp(current[i]->title,t)){\r
+               if(!strcmp(current[i].title.c_str(),t)){\r
                        return true;\r
                }\r
        }\r
index 0ed39fd1d0444d9c4a73e01e518a390551737004..9f9b05e11b0ba460e3994a9684b31308252224c3 100644 (file)
@@ -15,12 +15,31 @@ XMLDocument xml;
 void readConfig(void){
        XMLElement *scr;
        XMLElement *vol;
+       
+       unsigned int uval;
+       bool bval;
+       //float fval;
+       
        xml.LoadFile("config/settings.xml");
        scr = xml.FirstChildElement("screen");
-       SCREEN_WIDTH  = scr->UnsignedAttribute("width");
+       
+       if(scr->QueryUnsignedAttribute("width",&uval) == XML_NO_ERROR)
+               SCREEN_WIDTH = uval;
+       else SCREEN_WIDTH = 1280;
+       if(scr->QueryUnsignedAttribute("height",&uval) == XML_NO_ERROR)
+               SCREEN_HEIGHT = uval;
+       else SCREEN_HEIGHT = 800;
+       if(scr->QueryBoolAttribute("fullscreen",&bval) == XML_NO_ERROR)
+               FULLSCREEN = bval;
+       else FULLSCREEN = false;
+       if(xml.FirstChildElement("hline")->QueryUnsignedAttribute("size",&uval) == XML_NO_ERROR)
+               HLINE = uval;
+       else HLINE = 3;
+       
+       /*SCREEN_WIDTH  = scr->UnsignedAttribute("width");
        SCREEN_HEIGHT = scr->UnsignedAttribute("height");
        FULLSCREEN    = scr->BoolAttribute("fullscreen");
-       HLINE         = xml.FirstChildElement("hline")->UnsignedAttribute("size");
+       HLINE         = xml.FirstChildElement("hline")->UnsignedAttribute("size");*/
 
        vol = xml.FirstChildElement("volume");
        VOLUME_MASTER = vol->FirstChildElement("master")->FloatAttribute("volume");
index 4c1d32629a73002e4b8c0208b6ae25e937c41865..caf3d593c68290f249248055c2cb6b5d1dd0137f 100644 (file)
@@ -2,7 +2,6 @@
 #include <ui.h>
 
 #include <istream>
-//#include <unistd.h>
 
 extern std::istream *names;
 extern unsigned int loops;
@@ -105,7 +104,6 @@ Player::Player(){ //sets all of the player specific traits on object creation
                                                        "assets/playerk6.png",
                                                        "assets/playerk7.png",
                                                        "assets/playerk8.png");
-       //tex = new Texturec(3, "assets/maybeplayer.png", "assets/maybeplayer.png", "assets/maybeplayer.png");
        inv = new Inventory(PLAYER_INV_SIZE);
 }
 Player::~Player(){
@@ -214,8 +212,7 @@ Object::Object(){
        inv = NULL;
 }
 
-Object::Object(/*ITEM_ID id*/std::string in, const char *pd){
-       //identifier = id;
+Object::Object(std::string in, const char *pd){
        iname = in;
 
        if(pd){
@@ -256,7 +253,6 @@ void Object::reloadTexture(void){
 void Entity::draw(void){               //draws the entities
        glPushMatrix();
        glColor3ub(255,255,255);
-       //glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0);
        if(type==NPCT){
                if(NPCp(this)->aiFunc.size()){
                        glColor3ub(255,255,0);
@@ -279,7 +275,6 @@ void Entity::draw(void){            //draws the entities
        case PLAYERT:
                static int texState = 0;
                if(speed && !(loops % (int)(2.0f/(float)speed))){
-                       //currentWorld->addParticle(loc.x,loc.y-HLINE,HLINE,HLINE,0,0,{0.0f,.17f,0.0f},1000);
                        if(++texState==9)texState=1;
                        glActiveTexture(GL_TEXTURE0);
                        tex->bind(texState);
@@ -316,20 +311,9 @@ void Entity::draw(void){           //draws the entities
        case STRUCTURET:
                for(auto &strt : currentWorld->build){
                        if(this == strt){
-                               switch(strt->bsubtype){
-                                       /*case HOUSE:
-                                               glActiveTexture(GL_TEXTURE1);
-                                               ntex->bind(0);
-                                               //When rendering an objectwith this program.
-                                               glActiveTexture(GL_TEXTURE0);
-                                               tex->bind(0);
-                                               //glBindSampler(0, linearFiltering);
-                                               break;*/
-                                       default:
-                                               glActiveTexture(GL_TEXTURE0);
-                                               tex->bind(0);
-                                               break;
-                               }
+                               glActiveTexture(GL_TEXTURE0);
+                               tex->bind(0);
+                               break;
                        }
                } 
                break;
@@ -355,8 +339,7 @@ NOPE:
        if(near)ui::putStringCentered(loc.x+width/2,loc.y-ui::fontSize-HLINE/2,name);
 }
 
-void Player::interact(){ //the function that will cause the player to search for things to interact with
-       
+void Player::interact(){
 }
 
 /*
@@ -483,15 +466,8 @@ unsigned int Structures::spawn(BUILD_SUB sub, float x, float y){
         *      tempN is the amount of entities that will be spawned in the village. Currently the village
         *      will spawn bewteen 2 and 7 villagers for the starting hut.
        */
-       /* tex = new Texturec(7,"assets/townhall.png",
-                                                       "assets/house1.png", 
-                                                       "assets/house2.png", 
-                                                       "assets/house1.png", 
-                                                       "assets/house1.png", 
-                                                       "assets/fountain1.png",
-                                                       "assets/lampPost1.png")*/;
 
-       unsigned int tempN = (getRand() % 5 + 2);
+       //unsigned int tempN = (getRand() % 5 + 2);
        switch(sub){
                case TOWN_HALL:
                        tex = new Texturec(1, sTexLoc[sub].c_str());
@@ -503,15 +479,6 @@ unsigned int Structures::spawn(BUILD_SUB sub, float x, float y){
                        tex = new Texturec(1, sTexLoc[sub].c_str());
                        width =  50 * HLINE;
                        height = 40 * HLINE;
-                       for(unsigned int i = 0;i < tempN;i++){
-                       
-                               /*
-                                *      This is where the entities actually spawn. A new entity is created
-                                *      with type NPC.
-                               */
-                       
-                               //oi->addNPC(loc.x + i * HLINE ,100);
-                       }
                        break;
                case FOUNTAIN:
                        tex = new Texturec(1, sTexLoc[sub].c_str());
@@ -522,13 +489,11 @@ unsigned int Structures::spawn(BUILD_SUB sub, float x, float y){
                        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;
@@ -559,7 +524,6 @@ void Mob::wander(int timeRun){
                YAYA = false;
                currentWorld = a;
                ui::toggleWhiteFast();
-               //player->health-=5;
        }
        
        switch(subtype){
@@ -587,13 +551,8 @@ void Mob::wander(int timeRun){
                break;
        case MS_TRIGGER:
                if(player->loc.x + player->width / 2 > loc.x             &&
-                  player->loc.x + player->width / 2 < loc.x + width ){
-                       //if(!vfork()){
-                               hey(this);
-                               /*_exit(0);
-                       }*/
-                       
-               }
+                  player->loc.x + player->width / 2 < loc.x + width )
+                       hey(this);
                break;
        case MS_PAGE:
                if(player->loc.x > loc.x - 100           &&
index 724ca9c43be7dd1366bec79f8df88f50e6e9886b..bf37256f838f08a0859eb20fe88f31e1a58268a2 100644 (file)
@@ -60,6 +60,19 @@ int commonAIFunc(NPC *speaker){
        do{
                if(!strcmp(exml->Name(),"text")){
                        if(exml->UnsignedAttribute("id") == (unsigned)speaker->dialogIndex){
+
+                               /*
+                                * Handle any quest tags
+                                */
+       
+                               if((oxml = exml->FirstChildElement("quest"))){
+                                       const char *qname;
+                                       while(oxml){
+                                               if((qname = oxml->Attribute("assign")))
+                                                       player->qh.current.push_back((Quest){qname,"None",(struct item_t){0,0}});
+                                               oxml = oxml->NextSiblingElement();
+                                       }
+                               }
                                
                                /*
                                 * Handle any 'give' requests.
index 4d948316076e4594e2bb95e58975b943cb85d7c3..de6003054753e83132c0325758e828ce14c8bfcb 100644 (file)
@@ -71,11 +71,7 @@ int Inventory::takeItem(std::string name,uint count){
        return -1;
 }
 
-/*static const Item item[ITEM_COUNT]= {
-       #include "../config/items.h"
-};*/
-
-static GLuint *itemtex;//[ITEM_COUNT];
+static GLuint *itemtex;
 void itemDraw(Player *p,uint id);
 
 void initInventorySprites(void){
@@ -103,10 +99,6 @@ const char *getItemTexturePath(std::string name){
        return NULL;
 }
 
-/*char *getItemTexturePath(ITEM_ID id){
-       return item[id].textureLoc;
-}*/
-
 float getItemWidth(std::string name){
        for(auto &i : itemMap){
                if(i->name == name)
@@ -115,10 +107,6 @@ float getItemWidth(std::string name){
        return 0;
 }
 
-/*int getItemWidth(ITEM_ID id){
-       return item[id].width;
-}*/
-
 float getItemHeight(std::string name){
        for(auto &i : itemMap){
                if(i->name == name)
@@ -127,74 +115,18 @@ float getItemHeight(std::string name){
        return 0;
 }
 
-/*int getItemHeight(ITEM_ID id){
-       return item[id].height;
-}*/
-
-/*Item::Item(ITEM_ID i, const char *n, ITEM_TYPE t, float w, float h, int m, const char *tl){
-       id = i;
-       type = t;
-       width = w;
-       height = h;
-       maxStackSize = m;
-
-       name            = new char[strlen(n)+1];
-       textureLoc      = new char[strlen(tl)+1];
-
-       strcpy(name,n);
-       strcpy(textureLoc,tl);
-
-       //tex= new Texturec(1,textureLoc);
-}*/
-
 Inventory::Inventory(unsigned int s){
        sel=0;
        size=s;
-       //inv = new struct item_t[size];
-       //memset(inv,0,size*sizeof(struct item_t));
 }
 
 Inventory::~Inventory(void){
-       //delete[] inv;
 }
 
 void Inventory::setSelection(unsigned int s){
        sel=s;
 }
 
-/*int Inventory::addItem(ITEM_ID id,unsigned char count){
-       //std::cout << id << "," << inv[os].id << std::endl;
-       
-       for(unsigned int i = 0; i < size; i++){
-               if(inv[i].id == id){
-                       inv[i].count += count;
-                       return 0;
-               }
-       }
-       inv[os].id = id;
-       inv[os].count += count;
-       os++;
-
-#ifdef DEBUG
-       DEBUG_printf("Gave player %u more %s(s)(ID: %d).\n",count,item[id].name,item[id].id);
-#endif // DEBUG
-
-       return 0;
-}*/
-
-/*int Inventory::takeItem(ITEM_ID id,unsigned char count){
-       for(unsigned int i = 0;i < size;i++){
-               if(inv[i].id == id){
-#ifdef DEBUG
-                       DEBUG_printf("Took %u of player's %s(s).\n",count,item[i].name);
-#endif // DEBUG
-                       inv[i].count-=count;
-                       return 0;
-               }
-       }
-       return -1;
-}*/
-
 void Inventory::draw(void){
        static unsigned int lop = 0;
        const unsigned int numSlot = 7;
@@ -213,13 +145,9 @@ void Inventory::draw(void){
                r.start.x = player->loc.x + (player->width/2);
                r.start.y = player->loc.y + (player->height/2);
                curCoord[a++] = r.start;
-               //dfp[a] = 0;
-               //a++;
        }a=0;
        
-       if(invOpening){
-               //end = 0;
-               
+       if(invOpening){         
                for(auto &d : dfp){
                        if(!a || dfp[a - 1] > 50)
                                d += 1.65 * deltaTime;
@@ -228,7 +156,6 @@ void Inventory::draw(void){
                        a++;
                }a=0;
                
-               // if(end < numSlot)
                if(numSlot > 0)invOpen=true;
        }else{
                for(auto &d : dfp){
@@ -262,10 +189,10 @@ void Inventory::draw(void){
 
                        if(!items.empty() && a < items.size() && items[a].count){
                                glEnable(GL_TEXTURE_2D);
-                               glBindTexture(GL_TEXTURE_2D, itemtex[items[a].id/*inv[a].id*/]);
+                               glBindTexture(GL_TEXTURE_2D, itemtex[items[a].id]);
                                glColor4f(1.0f, 1.0f, 1.0f, ((float)dfp[a]/(float)(range?range:1))*0.8f);
                                glBegin(GL_QUADS);
-                                       if(itemMap[items[a].id]->height > itemMap[items[a].id]->width){//item[inv[a].id].width){
+                                       if(itemMap[items[a].id]->height > itemMap[items[a].id]->width){
                                                glTexCoord2i(0,1);glVertex2i(r.end.x-((itemWide/2)*((float)itemMap[items[a].id]->width/(float)itemMap[items[a].id]->height)),   r.end.y-(itemWide/2));
                                                glTexCoord2i(1,1);glVertex2i(r.end.x+((itemWide/2)*((float)itemMap[items[a].id]->width/(float)itemMap[items[a].id]->height)),   r.end.y-(itemWide/2));
                                                glTexCoord2i(1,0);glVertex2i(r.end.x+((itemWide/2)*((float)itemMap[items[a].id]->width/(float)itemMap[items[a].id]->height)),   r.end.y+(itemWide/2));
@@ -284,7 +211,7 @@ void Inventory::draw(void){
 
                        a++;
                        
-                       if(sel == a){
+                       if(sel == a - 1){
                                glBegin(GL_LINES);
                                        glColor4f(1.0f, 0.0f, 0.0f, 0.0f);
                                        glVertex2i(r.start.x,r.start.y);
@@ -359,14 +286,13 @@ void Inventory::draw(void){
                                }
                        glEnd();
                        glDisable(GL_TEXTURE_2D);
-                       //ui::putText(r.end.x-(itemWide/2)+(itemWide*.85),r.end.y-(itemWide/1.75),"%d",inv[a].count);
 
                        a++;
                }
                ui::putStringCentered(player->loc.x+player->width/2, player->loc.y + range*.75,itemMap[items[highlight].id]->name.c_str());
        }
        
-       if(!items.empty() && items[sel].count)
+       if(!items.empty() && items.size() > sel && items[sel].count)
                itemDraw(player,items[sel].id);
        lop++;
 }
@@ -383,13 +309,11 @@ void itemDraw(Player *p,uint id){
                        if(hangle < 15){
                                hangle=15.0f;
                                p->inv->usingi = false;
-                               //swing=false;
                        }
                }else{
                        if(hangle > -15){
                                hangle=-15.0f;
                                p->inv->usingi = false;
-                               //swing=false;
                        }
                }
        }else hangle = 0.0f;
@@ -416,7 +340,6 @@ void itemDraw(Player *p,uint id){
 
 int Inventory::useItem(void){
        static bool up = false;
-       //ITEM_TYPE type = item[inv[sel].id].type;
        if(!invHover){
                
                if(itemMap[items[sel].id]->type == "Sword"){
@@ -430,23 +353,11 @@ int Inventory::useItem(void){
                                        if(hangle==15){up=true;Mix_PlayChannel(2,swordSwing,0);}
                                        if(up)hangle+=.75*deltaTime;
                                        if(hangle>=90)hangle=14;
-                                       /*
-                                       if(hangle<90&&!up)hangle+=.75*deltaTime;
-                                       if(hangle>=90&&!up)up=true;
-                                       if(up)hangle-=.75*deltaTime;
-                                       if(up&&hangle<=15){
-                                               up=false;
-                                               swing=false;
-                                               hangle=15;
-                                               return 0;
-                                       }*/
                                }
                        }else if(!swing){
                                swing=true;
                                Mix_PlayChannel(2,swordSwing,0);
                        }
-                       //hangle++;
-                       //break;
                }
        }
        return 0;
index 91fa279ea4bdf3985c90fd53b785483589692309..65e1673c2ecb8c885caf3c92e8ac560686ad214a 100644 (file)
@@ -221,13 +221,13 @@ namespace ui {
                         *      making it white-on-black.
                        */
                        
-                       buf = new char[ftf->glyph->bitmap.width * ftf->glyph->bitmap.rows * 4]; //(char *)malloc(ftf->glyph->bitmap.width*ftf->glyph->bitmap.rows*4);
+                       buf = new char[ftf->glyph->bitmap.width * ftf->glyph->bitmap.rows * 4];
                
                        for(j=0;j<ftf->glyph->bitmap.width*ftf->glyph->bitmap.rows;j++){
                                buf[j*4  ]=fontColor[0];
                                buf[j*4+1]=fontColor[1];
                                buf[j*4+2]=fontColor[2];
-                               buf[j*4+3]=ftf->glyph->bitmap.buffer[j];
+                               buf[j*4+3]=ftf->glyph->bitmap.buffer[j] ? 255 : 0;
                        }
                        
                        ftexwh[i-33].x=ftf->glyph->bitmap.width;
@@ -631,7 +631,7 @@ namespace ui {
                                
                                for(auto &c : player->qh.current){
                                        hub.y -= fontSize * 1.15;
-                                       putString(hub.x,hub.y,c->title);
+                                       putString(hub.x,hub.y,c.title.c_str());
                                }       
                        }
                }
@@ -765,7 +765,9 @@ namespace ui {
                                                offset.x+m.button.loc.x + m.button.dim.x, 
                                                offset.y+m.button.loc.y + m.button.dim.y);
                                //draw the button text
-                               putStringCentered(offset.x + m.button.loc.x + (m.button.dim.x/2), (offset.y + m.button.loc.y + (m.button.dim.y/2)) - ui::fontSize/2, m.button.text);
+                               putStringCentered(offset.x + m.button.loc.x + (m.button.dim.x/2),
+                                                                 (offset.y + m.button.loc.y + (m.button.dim.y/2)) - ui::fontSize/2,
+                                                                 m.button.text);
                                
                                //tests if the mouse is over the button
                                if(mouse.x >= offset.x+m.button.loc.x && mouse.x <= offset.x+m.button.loc.x + m.button.dim.x){
index df0f0ac15593ba8e9f583b866bb2c735f48a34bc..71260952e4bfa3dddf37eda950b504bc78138a0e 100644 (file)
@@ -1371,13 +1371,23 @@ void IndoorWorld::draw(Player *p){
 
 extern bool inBattle;
 
+std::vector<World *> battleNest;
+std::vector<vec2>    battleNestLoc;
+
 Arena::Arena(World *leave,Player *p,Mob *m){
        generate(800);
        addMob(MS_DOOR,100,100);
+       
        inBattle = true;
-       exit = leave;
-       pxy = p->loc;
        mmob = m;
+       //exit = leave;
+       //pxy = p->loc;
+       
+       mob.push_back(m);
+       entity.push_back(m);
+       
+       battleNest.push_back(leave);
+       battleNestLoc.push_back(p->loc);
        
        star = new vec2[100];
        memset(star,0,100 * sizeof(vec2));
@@ -1392,14 +1402,20 @@ Arena::~Arena(void){
 }
 
 World *Arena::exitArena(Player *p){
+       World *tmp;
        if(p->loc.x + p->width / 2 > mob[0]->loc.x                              &&
           p->loc.x + p->width / 2 < mob[0]->loc.x + HLINE * 12 ){
-               inBattle = false;
+               tmp = battleNest.front();
+               battleNest.erase(battleNest.begin());
+               
+               inBattle = !battleNest.empty();
                ui::toggleBlackFast();
                ui::waitForCover();
-               p->loc = pxy;
-               mmob->alive = false;
-               return exit;
+               
+               p->loc = battleNestLoc.back();
+               battleNestLoc.pop_back();
+               //mmob->alive = false;
+               return tmp;
        }else{
                return this;
        }
index 6fe220cedb0896cb2417b50225bfa754547ed6b1..129ff4644e3cd191594673cd5ca96fa6262665fe 100644 (file)
@@ -34,6 +34,7 @@
 <Dialog name="Johnny">
        <text id="0" nextid="1" stop="true">
                Sup bro!
+               <quest assign="Quest #1" />
        </text>
        
        <text id="1" >