]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
Started inv ui, new item system
authordrumsetmonkey <abelleisle@roadrunner.com>
Fri, 20 Nov 2015 13:47:34 +0000 (08:47 -0500)
committerdrumsetmonkey <abelleisle@roadrunner.com>
Fri, 20 Nov 2015 13:47:34 +0000 (08:47 -0500)
13 files changed:
assets/invUI.png [new file with mode: 0644]
config/items.h [new file with mode: 0644]
config/quest_list.txt
include/entities.h
include/inventory.h
include/world.h
main.cpp
src/Quest.cpp
src/entities.cpp
src/gameplay.cpp
src/inventory.cpp
src/ui.cpp
src/world.cpp

diff --git a/assets/invUI.png b/assets/invUI.png
new file mode 100644 (file)
index 0000000..8647e38
Binary files /dev/null and b/assets/invUI.png differ
diff --git a/config/items.h b/config/items.h
new file mode 100644 (file)
index 0000000..a3ec683
--- /dev/null
@@ -0,0 +1,44 @@
+ID DEBUG_ITEM
+       NAME "Debug"
+       TYPE TOOL 
+       WIDTH 1 
+       HEIGHT 1 
+       STACKSIZE 1 
+       TEX "assets/items/ITEM_TEST.png"
+       ENI
+
+ID TEST_ITEM   
+       NAME "Dank MayMay" 
+       TYPE TOOL 
+       WIDTH HLINE 
+       HEIGHT HLINE 
+       STACKSIZE 420 
+       TEX "assets/items/ITEM_TEST.png"
+       ENI
+
+ID PLAYER_BAG  
+       NAME "Your Bag" 
+       TYPE EQUIP 
+       WIDTH HLINE*5 
+       HEIGHT HLINE*5 
+       STACKSIZE 1 
+       TEX "assets/items/ITEM_TEST.png"
+       ENI
+
+ID FLASHLIGHT  
+       NAME "Flashlight" 
+       TYPE TOOL 
+       WIDTH HLINE*2 
+       HEIGHT HLINE*4 
+       STACKSIZE 1 
+       TEX "assets/items/ITEM_TEST.png" 
+       ENI
+
+ID SWORD_WOOD  
+       NAME "Wood Sword" 
+       TYPE SWORD 
+       WIDTH HLINE*4 
+       HEIGHT HLINE*10 
+       STACKSIZE 1 
+       TEX "assets/items/ITEM_SWORD.png" 
+       STOP
\ No newline at end of file
index d23743ecc0dc5a438eb42fcee64fd0fc4a5cce59..3014ede6895d44f0a795da2d8d319bb920f3dd42 100644 (file)
@@ -1 +1 @@
-TITLE "Test" DESC "A test quest" REWARD 1 x SWORD_ITEM END
+TITLE "Test" DESC "A test quest" REWARD 1 x TEST_ITEM END
index b590c8d1d7472bd2718322ca23681d2de2d601c7..fe316ad2c59914e208e64a4b92136dea49827e3e 100644 (file)
@@ -110,9 +110,12 @@ public:
 class Object : public Entity{
 public:
        Object(int);
+       Object(int, bool, char*);
        void interact();
+       bool questObject = false;
+       char *pickupDialog;
 private:
-       int ID;
+       int identifier;
 };
 #endif // ENTITIES_H
 
index d2b4c2858975972c0b318761a4bc5e9b4336da86..dc5c04e34b348b2098413fbb4d474678213091fb 100644 (file)
@@ -5,26 +5,82 @@
 
 #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.
 */
 
+static unsigned int sel;
+
 enum ITEM_ID {
+       DEBUG_ITEM = 69,
        TEST_ITEM = 1,
-       SWORD_ITEM      = 2
+       PLAYER_BAG = 2,
+       FLASHLIGHT = 3,
+       SWORD_WOOD = 4
+};
+
+enum ITEM_TYPE{
+       TOOL = 1,
+       SWORD = 2,
+       RANGED = 3,
+       EQUIP = 4,
+       FOOD = 5
 };
 
-struct item_t {                                // Used to define entries in an entity's inventory
-       short count;                    // Quantity of the item in this slot
+class Item{
+protected:
+public:
+       friend class Inventory;
+       friend unsigned int initInventorySprites(void);
        ITEM_ID id;                             // ID of the item
-} __attribute__ ((packed));
+       char *name;
+       ITEM_TYPE type;                 // What category the item falls under
+       float width;
+       float height;
+       int maxStackSize;
+       char* textureLoc;
+       int count;
+       Item(ITEM_ID i, char* n, ITEM_TYPE t, float w, float h, int m, char* tl):
+               id(i), name(n), type(t), width(w), height(h), maxStackSize(m), textureLoc(tl){
+               count = 0;
+       }
+       void addCount(int c){
+               count += c;
+       }
+
+};
+
+static Item item[5]= {
+       #include "../config/items.h"
+};
+
+struct item_t{
+       int count;
+       ITEM_ID itmid;
+       void addC(int c, ITEM_ID i){
+               count = c;
+               itmid = i;
+               item[itmid].addCount(count);
+       }
+} __attribute__((packed));
+
 
 class Inventory {
 private:
-       unsigned int sel;
        unsigned int size;              // Size of 'item' array
-       struct item_t *item;    // An array of the items contained in this inventory.
+       //struct item_t *item;  // An array of the items contained in this inventory.
 public:
+
        Inventory(unsigned int s);      // Creates an inventory of size 's'
        ~Inventory(void);                       // Free's 'item'
        
index ac41dd66c0bbd070fedd8e68565ea7017d716473..3d5fdadb65edff3de77651033578fc0c0547cfee 100644 (file)
@@ -85,6 +85,8 @@ public:
        void addMob(int t,float x,float y);
        void addNPC(float x,float y);
        void addObject(int, float, float);
+       void addObject(int, bool, char*, float, float);
+
 
        //void removeObjet(Object);
        
index ebeabd405b076c3fa4b51274f0048096ddf9ae4f..397c9da78ebcfa09ab3dd60f8edd77640d770960 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -1,3 +1,8 @@
+/*! @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.
+*/
+
 #include <cstdio> // fopen
 #include <chrono> // see millis()
 
@@ -50,7 +55,7 @@ SDL_GLContext  mainGLContext = NULL;
  *
 */
 
-static GLuint  bgDay, bgNight, bgMtn, bgTreesFront, bgTreesMid, bgTreesFar;
+GLuint  bgDay, bgNight, bgMtn, bgTreesFront, bgTreesMid, bgTreesFar, invUI;
 
 /*
  *     gameRunning
@@ -187,9 +192,9 @@ std::string readFile(const char *filePath) {
  *     everything can be moved according to the player
 */
 
-vec2 offset;                                                                                                                                                   /**     OFFSET!!!!!!!!!!!!!!!!!!!! **/
+vec2 offset;                                                                                                                                                   /*      OFFSET!!!!!!!!!!!!!!!!!!!! */
 
-/*
+/**
  *     millis
  *
  *     We've encountered many problems when attempting to create delays for triggering
@@ -197,7 +202,7 @@ vec2 offset;                                                                                                                                                        /**     OFFSET!!!!!!!!!!!!!!!!!!!! **/
  *     by <chrono> in the standard C++ library. This function simply returns the amount
  *     of milliseconds that have passed sine the epoch.
  *
-*/
+**/
 
 #ifdef __WIN32__
 #define millis()       SDL_GetTicks()
@@ -218,6 +223,7 @@ typedef enum {
 
 static WEATHER weather = SUNNY;
 static vec2 star[100];
+static unsigned char fadeIntensity = 0;
 
 
 /*******************************************************************************
@@ -227,7 +233,7 @@ static vec2 star[100];
 int main(int argc, char *argv[]){
        gameRunning=false;
 
-       /*
+       /*!
         *      (Attempt to) Initialize SDL libraries so that we can use SDL facilities and eventually
         *      make openGL calls. Exit if there was an error.
        */
@@ -240,10 +246,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.
-       */
+       **/
 
        if(!(IMG_Init(IMG_INIT_PNG) & IMG_INIT_PNG)){
                std::cout << "Could not init image libraries! Error: " << IMG_GetError() << std::endl;
@@ -253,10 +259,10 @@ 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.
         *
-       */
+       **/
 
        if(Mix_OpenAudio( 44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0){
                std::cout << "SDL_mixer could not initialize! Error: " << Mix_GetError() << std::endl;
@@ -415,7 +421,7 @@ int main(int argc, char *argv[]){
         *      src/gameplay.cpp
         * 
        */
-       
+       fadeIntensity = 254;
        initEverything();
        
        /*
@@ -440,12 +446,15 @@ int main(int argc, char *argv[]){
        bgTreesFront =Texture::loadTexture("assets/bgFrontTree.png"      );
        bgTreesMid       =Texture::loadTexture("assets/bgMidTree.png"    );
        bgTreesFar       =Texture::loadTexture("assets/bgFarTree.png"    );
+       invUI            =Texture::loadTexture("assets/invUI.png"                );
        
        /*
         *      Load sprites used in the inventory menu. See src/inventory.cpp
        */
        
+       std::cout << "Before invSprites\n";
        initInventorySprites();
+       std::cout << "After invSprites\n";
        
        /*
         *      Generate coordinates for stars that are drawn at night.
@@ -460,7 +469,6 @@ int main(int argc, char *argv[]){
        /**************************
        ****     GAMELOOP      ****
        **************************/
-       
        gameRunning=true;
        while(gameRunning){
                mainLoop();
@@ -524,7 +532,6 @@ void mainLoop(void){
        /*
         *      Run the logic handler if MSEC_PER_TICK milliseconds have passed.
        */
-       
        if(prevPrevTime + MSEC_PER_TICK >= currentTime){
                logic();
                prevPrevTime = currentTime;
@@ -555,7 +562,6 @@ void mainLoop(void){
 }
 
 extern bool fadeEnable;
-static unsigned char fadeIntensity = 0;
 
 void render(){
        
@@ -774,16 +780,18 @@ void render(){
                glUseProgramObjectARB(0);
        #endif //SHADERS
 
-       if(player->light){
-               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){
-                       if(handAngle <= 0)
-                               handAngle+=180;
-                       if(ui::mouse.y < player->loc.y + player->height/2){
-                               handAngle+=180;
-                       }
+       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){
+               if(handAngle <= 0)
+                       handAngle+=180;
+               if(ui::mouse.y < player->loc.y + player->height/2){
+                       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 && 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;
@@ -828,7 +836,7 @@ void render(){
                                        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){
+                                       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;
@@ -985,6 +993,8 @@ void logic(){
         *
        */
 
+       if((SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT)) && !ui::dialogBoxExists)player->inv->useItem();
+
        for(auto &n : currentWorld->npc){
                if(n->alive){
                        /*
@@ -1076,7 +1086,11 @@ void logic(){
        unsigned int i = 0;
        for(auto &o : currentWorld->object){
                if(o->alive){
-                       if(pow((o->loc.x - player->loc.x),2) + pow((o->loc.y - player->loc.y),2) <= pow(40*HLINE,2)){
+                       if(ui::mouse.x >= o->loc.x                              &&
+                          ui::mouse.x <= o->loc.x + o->width   &&
+                          ui::mouse.y >= o->loc.y                              &&
+                          ui::mouse.y <= o->loc.y + o->width   ){
+                               if(pow((o->loc.x - player->loc.x),2) + pow((o->loc.y - player->loc.y),2) <= pow(40*HLINE,2)){
 
                                        /*
                                         *      Check for a right click, and allow the Object to interact with the
@@ -1088,6 +1102,7 @@ void logic(){
                                                o->interact();
                                        }
                                }
+                       }
                }
                if(!(o->alive)){
                        currentWorld->object.erase(currentWorld->object.begin()+i);
index a36141851997f90e4f43c56ca3e4acb2ccea0a51..5fd7726fbb6a9ec62788f5c5d44a19bb18348fb3 100644 (file)
@@ -85,7 +85,7 @@ int QuestHandler::finish(const char *t,void *completer){
 #ifdef DEBUG\r
                        DEBUG_printf("Completing quest %s.\n",t);\r
 #endif // DEBUG\r
-                       ((Entity *)completer)->inv->addItem(current[i]->reward.id,current[i]->reward.count);\r
+                       ((Entity *)completer)->inv->addItem(current[i]->reward.itmid,current[i]->reward.count);\r
                        current.erase(current.begin()+i);\r
 #ifdef DEBUG\r
                        DEBUG_printf("QuestHandler now has %u active quests.\n",current.size());\r
index a8e9bfb5fc5a0f3be2e8883b6edd4670ff0e3e80..e979e330ed489b633ced2e39abadccaba376762a 100644 (file)
@@ -8,6 +8,8 @@ extern World *currentWorld;
 
 extern Player *player;
 
+extern const char *itemName;
+
 void Entity::spawn(float x, float y){  //spawns the entity you pass to it based off of coords and global entity settings
        loc.x = x;
        loc.y = y;
@@ -91,7 +93,21 @@ Mob::Mob(int sub){
        inv = new Inventory(NPC_INV_SIZE);
 }
 
-Object::Object(int id):ID(id){
+Object::Object(int id):identifier(id){
+       type = OBJECTT;
+       alive = true;
+       near = false;
+       width  = HLINE * 8;
+       height = HLINE * 8;
+
+       maxHealth = health = 1;
+       tex = new Texturec(1, "assets/items/ITEM_SWORD.png");
+
+       questObject = false;
+       pickupDialog="\0";
+}
+
+Object::Object(int id, bool qo, char *pd):identifier(id),questObject(qo),pickupDialog(pd){
        type = OBJECTT;
        alive = true;
        near = false;
@@ -175,8 +191,6 @@ void Entity::draw(void){            //draws the entities
                        default:
                        break;
                }
-       }else if(type == OBJECTT){
-               tex->bind(0);
        }else{
                tex->bind(0);
        }
@@ -294,9 +308,19 @@ void NPC::interact(){ //have the npc's interact back to the player
        }
 }
 
+extern void waitForDialog(void);
 void Object::interact(){
-       this->alive = false;
-       player->inv->addItem((ITEM_ID)(ID), (char)1);
+       if(questObject){
+               char opt[]=":No:Yes";
+               ui::dialogBox("You",opt,pickupDialog);
+               if(ui::dialogOptChosen == 1){
+                       this->alive = false;
+                       player->inv->addItem((ITEM_ID)(identifier), (char)1);
+               }
+       }else{
+               this->alive = false;
+               player->inv->addItem((ITEM_ID)(identifier), (char)1);
+       }
 }
 
 /*
index fcc501c6a06ac4081b76fa41f17813f2f7ee8788..18bf327fae043c60a0e763b6c544725d907c05bd 100644 (file)
@@ -6,6 +6,35 @@
 extern World   *currentWorld;
 extern Player  *player;
 extern void mainLoop(void);
+extern SDL_Window *window;
+extern bool fadeEnable;
+
+void story(void){
+       for(int i=0;i<600;i++){
+               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);
+               glMatrixMode(GL_MODELVIEW);
+               glPushMatrix();
+               glLoadIdentity();
+               glEnable(GL_STENCIL_TEST);
+               glPushMatrix();
+
+               glPushAttrib( GL_DEPTH_BUFFER_BIT | GL_LIGHTING_BIT );
+               glClear(GL_COLOR_BUFFER_BIT);
+
+               glColor4f(0.0f,0.0f,0.0f,0.0f);
+               glRectf(-SCREEN_WIDTH/2,0,SCREEN_WIDTH/2,SCREEN_HEIGHT);
+               glColor4f(1.0f,1.0f,1.0f,1.0f);
+               ui::importantText("Oh hello, where are you?");
+               //ui::setFontSize(16);
+               //ui::putText(54,540,"BITC.");
+
+               glPopMatrix();
+               SDL_GL_SwapWindow(window);
+       }
+}
 
 void waitForDialog(void){
        do{
@@ -110,12 +139,11 @@ void initEverything(void){
        test->addMob(MS_RABBIT,200,100);
        test->addMob(MS_BIRD,-500,500);
 
-       currentWorld->addObject(2, 500,200);
-       
+       currentWorld->addObject(SWORD_WOOD, 500,200);
+       currentWorld->addObject(FLASHLIGHT, true, "This looks important, do you want to pick it up?",600,200);
        /*
         *      Link all the entities that were just created to the initial world, and setup a test AI function. 
        */
        
        currentWorld->npc[0]->addAIFunc(giveTestQuest,false);
-       
 }
index 217fd18838d120b759c8c96832b08080a7a170d7..edc88ff59b6ebbfe0a7cd1590346170635f61e4b 100644 (file)
@@ -2,21 +2,10 @@
 #include <entities.h>
 #include <ui.h>
 
-#define ITEM_COUNT 2   // Total number of items that actually exist
+#define ITEM_COUNT 5   // Total number of items that actually exist
 
 extern Player *player;
-
-const char *itemName[]={
-       "\0",
-       "Dank Maymay",
-       "Sword"
-};
-
-const char *ITEM_SPRITE[]={
-       "\0",                                                   // Null
-       "assets/items/ITEM_TEST.png",   // Dank maymay
-       "assets/items/ITEM_SWORD.png"
-};
+extern GLuint invUI;
 
 GLuint *ITEM_TEX;
 
@@ -26,7 +15,7 @@ unsigned int initInventorySprites(void){
        unsigned int i,loadCount=0;
        ITEM_TEX=(GLuint *)calloc(ITEM_COUNT,sizeof(GLuint));
        for(i=0;i<ITEM_COUNT;i++){
-               if((ITEM_TEX[i]=Texture::loadTexture(ITEM_SPRITE[i+1])))loadCount++;
+               if((ITEM_TEX[i]=Texture::loadTexture(item[i].textureLoc)))loadCount++;
        }
 #ifdef DEBUG
        DEBUG_printf("Loaded %u/%u item texture(s).\n",loadCount,ITEM_COUNT);
@@ -37,7 +26,7 @@ unsigned int initInventorySprites(void){
 Inventory::Inventory(unsigned int s){
        sel=0;
        size=s;
-       item=(struct item_t *)calloc(size,sizeof(struct item_t));
+       //item=(struct item_t *)calloc(size,sizeof(struct item_t));
        tossd=false;
 }
 
@@ -51,22 +40,28 @@ void Inventory::setSelection(unsigned int s){
 
 int Inventory::addItem(ITEM_ID id,unsigned char count){
        unsigned int i;
+
        for(i=0;i<size;i++){
                if(item[i].id==id){
                        item[i].count+=count;
-#ifdef DEBUG
-                       DEBUG_printf("Gave player %u more %s(s).\n",count,itemName[item[i].id]);
-#endif // DEBUG
+
+                       #ifdef DEBUG
+                       DEBUG_printf("Gave player %u more %s(s).\n",count,item[i].name);
+                       #endif // DEBUG
+
                        return 0;
                }else if(!item[i].count){
                        item[i].id=id;
                        item[i].count=count;
-#ifdef DEBUG
-                       DEBUG_printf("Gave player %u %s(s).\n",count,itemName[item[i].id]);
-#endif // DEBUG
+
+                       #ifdef DEBUG
+                       DEBUG_printf("Gave player %u %s(s).\n",count,item[i].name);
+                       #endif // DEBUG
+
                        return 0;
                }
        }
+
 #ifdef DEBUG
        DEBUG_printf("Failed to add non-existant item with id %u.\n",id);
 #endif // DEBUG
@@ -78,7 +73,7 @@ int Inventory::takeItem(ITEM_ID id,unsigned char count){
        for(i=0;i<size;i++){
                if(item[i].id==id){
 #ifdef DEBUG
-                       DEBUG_printf("Took %u of player's %s(s).\n",count,itemName[item[i].id]);
+                       DEBUG_printf("Took %u of player's %s(s).\n",count,item[i].name);
 #endif // DEBUG
                        item[i].count-=count;
                        if(item[i].count<0)
@@ -92,12 +87,20 @@ int Inventory::takeItem(ITEM_ID id,unsigned char count){
 void Inventory::draw(void){
        unsigned int i=0;
        float y=offset.y,xoff;
-       ui::putText(offset.x-SCREEN_WIDTH/2,y,"Inventory:");
+       glEnable(GL_TEXTURE_2D);
+       glBindTexture(GL_TEXTURE_2D, invUI);
+       glBegin(GL_QUADS);
+               glTexCoord2i(0,1);glVertex2i(offset.x-SCREEN_WIDTH/2,                   0);
+               glTexCoord2i(1,1);glVertex2i(offset.x-SCREEN_WIDTH/2+261,               0);
+               glTexCoord2i(1,0);glVertex2i(offset.x-SCREEN_WIDTH/2+261,          57);
+               glTexCoord2i(0,0);glVertex2i(offset.x-SCREEN_WIDTH/2,              57);
+       glEnd();
+       glDisable(GL_TEXTURE_2D);
        while(item[i].count){
                y-=HLINE*12;
                xoff=ui::putText(offset.x-SCREEN_WIDTH/2,y,"%d x ",item[i].count);
                glEnable(GL_TEXTURE_2D);
-               glBindTexture(GL_TEXTURE_2D,ITEM_TEX[item[i].id-1]);
+               glBindTexture(GL_TEXTURE_2D,ITEM_TEX[item[i].id]);
                if(sel==i)glColor3ub(255,0,255);
                else      glColor3ub(255,255,255);
                glBegin(GL_QUADS);
@@ -107,7 +110,7 @@ void Inventory::draw(void){
                        glTexCoord2i(0,0);glVertex2i(xoff                 ,y+HLINE*10);
                glEnd();
                y-=ui::fontSize*1.15;
-               ui::putText(offset.x-SCREEN_WIDTH/2,y,"%s",itemName[(unsigned)item[i].id]);
+               ui::putText(offset.x-SCREEN_WIDTH/2,y,"%s",item[i].name);
                glDisable(GL_TEXTURE_2D);
                i++;
        }
@@ -132,10 +135,10 @@ void itemDraw(Player *p,ITEM_ID id){
        }
        if(p->inv->tossd) yes=true;
        glBegin(GL_QUADS);
-               glTexCoord2i(0,1);glVertex2f(item_coord.x+p1.x,item_coord.y+p2.y);
-               glTexCoord2i(1,1);glVertex2f(item_coord.x+p2.x,item_coord.y+p2.y);
-               glTexCoord2i(1,0);glVertex2f(item_coord.x+p2.x,item_coord.y+p1.y);
-               glTexCoord2i(0,0);glVertex2f(item_coord.x+p1.x,item_coord.y+p1.y);
+               glTexCoord2i(0,1);glVertex2f(item_coord.x+p->loc.x,                                             item_coord.y+p->loc.y);
+               glTexCoord2i(1,1);glVertex2f(item_coord.x+item[sel].width+p->loc.x,             item_coord.y+p->loc.y);
+               glTexCoord2i(1,0);glVertex2f(item_coord.x+item[sel].width+p->loc.x,             item_coord.y+item[sel].height+p->loc.y);
+               glTexCoord2i(0,0);glVertex2f(item_coord.x+p->loc.x,                                             item_coord.y+item[sel].height+p->loc.y);
        glEnd();
        glDisable(GL_TEXTURE_2D);
 }
@@ -143,8 +146,11 @@ void itemDraw(Player *p,ITEM_ID id){
 int Inventory::useItem(void){
        ITEM_ID id = item[sel].id;
        switch(id){
+       case SWORD_WOOD:
+
+               break;
        default:
-               ui::dialogBox(itemName[id],NULL,"You cannot use this item.");
+               ui::dialogBox(item[id].name,NULL,"You cannot use this item.");
                break;
        }
        return 0;
index bbec2ded7aaf538cf30901e8215da809b51d66c0..e6914d54152c56dae95a857eae0e803f36841236 100644 (file)
@@ -274,6 +274,7 @@ namespace ui {
                                width+=fontSize/2;
                        }else if(s[i]=='\b'){   //      Handle backspaces?
                                // Why?
+                               // Cuz
                        }else{
                                width+=ftexwh[i].x+fontSize*.1;
                        }
@@ -304,7 +305,7 @@ namespace ui {
                 *      Reset values if a new string is being passed.
                */
                
-               if(!size || ((linc>15)&(strncmp(ret,str,15)))){
+               if(strncmp(ret,str,linc-1)){
                        memset(ret,0,512);              //      Zero the buffer
                        size=strlen(str);               //      Set the new target string size
                        linc=0;                                 //      Reset the incrementers
@@ -470,7 +471,7 @@ namespace ui {
                        hub.y-=fontSize*1.15;
                        glRectf(hub.x,
                                        hub.y,
-                                       hub.x+(player->health/player->maxHealth)*100,
+                                       hub.x+(player->health/player->maxHealth)*130,
                                        hub.y+12);
                }
                
index 27574717dbece9c3161c99f28b09563b13768d57..8d003c9fcb368b22ed045dee1dda6b5c6d086ee0 100644 (file)
@@ -591,6 +591,13 @@ void World::addObject(int i, float x, float y){
        entity.push_back(object.back());
 }
 
+void World::addObject(int i, bool q, char *p, float x, float y){
+       object.push_back(new Object(i,q, p));
+       object.back()->spawn(x,y);
+
+       entity.push_back(object.back());
+}
+
 /*void World::removeObject(Object i){
        object.delete(i);
 }*/