]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
inv stuff
authordrumsetmonkey <abelleisle@roadrunner.com>
Fri, 4 Dec 2015 13:49:02 +0000 (08:49 -0500)
committerdrumsetmonkey <abelleisle@roadrunner.com>
Fri, 4 Dec 2015 13:49:02 +0000 (08:49 -0500)
12 files changed:
assets/items/SWORD_WOOD.png [new file with mode: 0644]
assets/names_en-us
assets/player.png
assets/player1.png
assets/player2.png
config/items.h
include/inventory.h
include/ui.h
main.cpp
src/entities.cpp
src/inventory.cpp
src/ui.cpp

diff --git a/assets/items/SWORD_WOOD.png b/assets/items/SWORD_WOOD.png
new file mode 100644 (file)
index 0000000..a6d3af3
Binary files /dev/null and b/assets/items/SWORD_WOOD.png differ
index c65808bdd2083131ddf6fbe22f967ff8d67869b6..a841bb891fd11ae60b8278aa68ead0815bc4c46c 100644 (file)
@@ -55,6 +55,7 @@ mPingu
 mShrek
 mLogan
 mJohn Cena
+mDex Dogtective
 fShani
 fIsidra
 fAja
index 88819801d863cdeab1d28efa8629847d075b1497..cfc327cb4b7e7b9608a52daaa5e4c1b701e4fcae 100644 (file)
Binary files a/assets/player.png and b/assets/player.png differ
index 33e68f2d1fef7a668283ef3f083ab279035be744..8204252bd8d602a76aed25b795ba422fbf9e9ca3 100644 (file)
Binary files a/assets/player1.png and b/assets/player1.png differ
index 20e679b647796bb5de34069f6896d12e40cbc643..63f4c08fa812dea612f366559d1aa56ce657ac21 100644 (file)
Binary files a/assets/player2.png and b/assets/player2.png differ
index fc0ca96a7fe7f59650a78869265badce632c8ea0..1bd9111edc9db036028144a054f8e9d3467ef724 100644 (file)
@@ -11,8 +11,8 @@ ID DEBUG_ITEM
 ID TEST_ITEM   
        NAME "Dank MayMay" 
        TYPE TOOL 
-       WIDTH HLINE 
-       HEIGHT HLINE 
+       WIDTH HLINE*1
+       HEIGHT HLINE*1 
        STACKSIZE 420 
        TEX "assets/items/ITEM_TEST.png"
        ENI
@@ -41,5 +41,5 @@ ID SWORD_WOOD
        WIDTH HLINE*4 
        HEIGHT HLINE*10 
        STACKSIZE 1 
-       TEX "assets/items/ITEM_SWORD.png" 
+       TEX "assets/items/SWORD_WOOD.png" 
        STOP
index 33a113ccaf7dcdcc80de7acd45d26cf53e09f872..5f05f3a0d5c21a84c2501fb50deb1c74995c9df4 100644 (file)
@@ -91,5 +91,7 @@ public:
 void itemUse(void *p);
 void initInventorySprites(void);
 char *getItemTexturePath(ITEM_ID id);
+int getItemWidth(ITEM_ID);
+int getItemHeight(ITEM_ID);
 
 #endif // INVENTORY_H
index 4d30b9b043fa5207de54bbd5415f95e028a4f449..f2c01148ead938b05a4b4590d3b309df4b077e80 100644 (file)
@@ -27,6 +27,7 @@ namespace ui {
        extern unsigned int fontSize;
        extern bool                      dialogBoxExists;
        extern unsigned char dialogOptChosen;
+       extern bool edown;
 
        /*
         *      Initializes the FreeType system.
index a273f0cd3da603323142bf94b74e2f8b84d46862..11fc181d51595f59f32e1d5ec4592c0264530623 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -214,7 +214,6 @@ static unsigned int fadeIntensity = 0;
 
 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.
index 729bcdd37079bbcc2a43f0ba65e71376928afa84..b1a0c0956dca784b244feef82a80a4523a73e491 100644 (file)
@@ -169,8 +169,8 @@ Object::Object(ITEM_ID id, bool qo, const char *pd){
        type = OBJECTT;
        alive = true;
        near = false;
-       width  = HLINE * 8;
-       height = HLINE * 8;
+       width  = getItemWidth(id);
+       height = getItemHeight(id);
 
        maxHealth = health = 1;
        tex = new Texturec(1,getItemTexturePath(id));
index 310a6b5ef6c1e3b03b35cd594b90d8ae2e3893cb..e6433bbda54d9076c7e874f7d4b984151d3662b5 100644 (file)
@@ -26,6 +26,14 @@ char *getItemTexturePath(ITEM_ID id){
        return item[id].textureLoc;
 }
 
+int getItemWidth(ITEM_ID id){
+       return item[id].width;
+}
+
+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;
@@ -179,7 +187,7 @@ void Inventory::draw(void){
                                highlight=sel+thing;
                                if(highlight>numSlot-1)highlight=numSlot-1;
                                if(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT)){
-                                       highlight>numSlot-1 ? sel=numSlot-1 : sel = highlight;
+                                       sel = highlight;
                                        mouseSel=false;
                                        invHover=false;
                                        selected = true;
@@ -205,10 +213,10 @@ void Inventory::draw(void){
 
                        glColor4f(0.0f, 0.0f, 0.0f, a == highlight ? 0.5f : 0.1f);
                        glBegin(GL_QUADS);
-                               glVertex2i(r.end.x-(itemWide/2),                        r.end.y-(itemWide/2));
-                               glVertex2i(r.end.x-(itemWide/2)+itemWide,       r.end.y-(itemWide/2));
-                               glVertex2i(r.end.x-(itemWide/2)+itemWide,       r.end.y-(itemWide/2)+itemWide);
-                               glVertex2i(r.end.x-(itemWide/2),                        r.end.y-(itemWide/2)+itemWide);
+                               glVertex2i(r.end.x-(itemWide/2),        r.end.y-(itemWide/2));
+                               glVertex2i(r.end.x+(itemWide/2),        r.end.y-(itemWide/2));
+                               glVertex2i(r.end.x+(itemWide/2),        r.end.y+(itemWide/2));
+                               glVertex2i(r.end.x-(itemWide/2),        r.end.y+(itemWide/2));
                        glEnd();
 
                        if(inv[a].count > 0){
@@ -216,16 +224,24 @@ void Inventory::draw(void){
                                glBindTexture(GL_TEXTURE_2D, itemtex[inv[a].id]);                       
                                glColor4f(1.0f, 1.0f, 1.0f, a == highlight ? 0.8f : 0.2f);
                                glBegin(GL_QUADS);
-                                       glTexCoord2i(0,1);glVertex2i(r.end.x-(itemWide/2),                      r.end.y-(itemWide/2));
-                                       glTexCoord2i(1,1);glVertex2i(r.end.x-(itemWide/2)+itemWide,     r.end.y-(itemWide/2));
-                                       glTexCoord2i(1,0);glVertex2i(r.end.x-(itemWide/2)+itemWide,     r.end.y-(itemWide/2)+itemWide);
-                                       glTexCoord2i(0,0);glVertex2i(r.end.x-(itemWide/2),                      r.end.y-(itemWide/2)+itemWide);
+                                       if(item[inv[a].id].height > item[inv[a].id].width){
+                                               glTexCoord2i(0,1);glVertex2i(r.end.x-((itemWide/2)*((float)item[inv[a].id].width/(float)item[inv[a].id].height)),       r.end.y-(itemWide/2));
+                                               glTexCoord2i(1,1);glVertex2i(r.end.x+((itemWide/2)*((float)item[inv[a].id].width/(float)item[inv[a].id].height)),       r.end.y-(itemWide/2));
+                                               glTexCoord2i(1,0);glVertex2i(r.end.x+((itemWide/2)*((float)item[inv[a].id].width/(float)item[inv[a].id].height)),       r.end.y+(itemWide/2));
+                                               glTexCoord2i(0,0);glVertex2i(r.end.x-((itemWide/2)*((float)item[inv[a].id].width/(float)item[inv[a].id].height)),       r.end.y+(itemWide/2));
+                                       }else{
+                                               glTexCoord2i(0,1);glVertex2i(r.end.x-(itemWide/2),      r.end.y-(itemWide/2)*((float)item[inv[a].id].height/(float)item[inv[a].id].width));
+                                               glTexCoord2i(1,1);glVertex2i(r.end.x+(itemWide/2),      r.end.y-(itemWide/2)*((float)item[inv[a].id].height/(float)item[inv[a].id].width));
+                                               glTexCoord2i(1,0);glVertex2i(r.end.x+(itemWide/2),      r.end.y+(itemWide/2)*((float)item[inv[a].id].height/(float)item[inv[a].id].width));
+                                               glTexCoord2i(0,0);glVertex2i(r.end.x-(itemWide/2),      r.end.y+(itemWide/2)*((float)item[inv[a].id].height/(float)item[inv[a].id].width));
+                                       }
                                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++;
                }
+               if(inv[highlight].count > 0)ui::putStringCentered(player->loc.x+player->width/2, player->loc.y + range*.75,item[inv[highlight].id].name);
        }
        if(inv[sel].count)itemDraw(player,inv[sel].id);
        lop++;
index db376b79ebbfc7b5dad29ef9b27af4312df39c53..6f5bdbe992ca3ee72f5597eba648a312d240c2af 100644 (file)
@@ -68,6 +68,11 @@ namespace ui {
        */
        
        vec2 mouse;
+
+       /*
+        *      Variety of keydown bools
+       */
+       bool edown;
        
        /*
         *      Debugging flags.
@@ -624,6 +629,7 @@ DONE:
                                if(SDL_KEY==SDLK_F3)debug^=true;
                                if(((SDL_KEY==SDLK_b) & (SDL_KEY==SDLK_F3)))posFlag^=true;
                                if(SDL_KEY==SDLK_e){
+                                       edown=true;
                                        if(heyOhLetsGo == 0){
                                                heyOhLetsGo = loops;
                                                player->inv->mouseSel = false;
@@ -646,6 +652,7 @@ DONE:
                                if(SDL_KEY==SDLK_h)player->health-=5;
                                if(SDL_KEY==SDLK_f)player->light ^= true;
                                if(SDL_KEY==SDLK_e){
+                                       edown=false;
                                        if(player->inv->invHover){
                                                player->inv->invHover = false;
                                                heyOhLetsGo = 0;