diff options
-rw-r--r-- | Changelog | 13 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | config/items.h | 10 | ||||
-rw-r--r-- | include/Texture.h | 3 | ||||
-rw-r--r-- | include/common.h | 11 | ||||
-rw-r--r-- | include/entities.h | 5 | ||||
-rw-r--r-- | include/inventory.h | 32 | ||||
-rw-r--r-- | main.cpp | 38 | ||||
-rw-r--r-- | src/Makefile | 2 | ||||
-rw-r--r-- | src/Quest.cpp | 11 | ||||
-rw-r--r-- | src/Texture.cpp | 2 | ||||
-rw-r--r-- | src/common.cpp | 26 | ||||
-rw-r--r-- | src/entities.cpp | 18 | ||||
-rw-r--r-- | src/gameplay.cpp | 7 | ||||
-rw-r--r-- | src/inventory.cpp | 187 | ||||
-rw-r--r-- | src/ui.cpp | 13 |
16 files changed, 223 insertions, 157 deletions
@@ -325,3 +325,16 @@ - moved background drawing to World class - re-did the item system - actually tiled background images to save space + +11/23/2015: +=========== + - 2 month Changelog anniversary :) + - Created the new inventory ui + - Fixed texture loading bugs + +11/24/2015: +=========== + + - Bug fixes related to memory allocation + - Broke item textures... + - Finshed new inventory ui animations @@ -1,4 +1,4 @@ -LIBS = -lGL -lGLEW -lSDL2 -lfreetype -lSDL2_image -lSDL2_mixer
+LIBS = -lpthread -lGL -lGLEW -lSDL2 -lfreetype -lSDL2_image -lSDL2_mixer
WIN_LIBS = -lopengl32 -lglew32 -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer -lfreetype
diff --git a/config/items.h b/config/items.h index a3ec683..3189a29 100644 --- a/config/items.h +++ b/config/items.h @@ -1,5 +1,5 @@ ID DEBUG_ITEM - NAME "Debug" + NAME "Debug\0" TYPE TOOL WIDTH 1 HEIGHT 1 @@ -8,7 +8,7 @@ ID DEBUG_ITEM ENI ID TEST_ITEM - NAME "Dank MayMay" + NAME "Dank MayMay\0" TYPE TOOL WIDTH HLINE HEIGHT HLINE @@ -17,7 +17,7 @@ ID TEST_ITEM ENI ID PLAYER_BAG - NAME "Your Bag" + NAME "Your Bag\0" TYPE EQUIP WIDTH HLINE*5 HEIGHT HLINE*5 @@ -26,7 +26,7 @@ ID PLAYER_BAG ENI ID FLASHLIGHT - NAME "Flashlight" + NAME "Flashlight\0" TYPE TOOL WIDTH HLINE*2 HEIGHT HLINE*4 @@ -35,7 +35,7 @@ ID FLASHLIGHT ENI ID SWORD_WOOD - NAME "Wood Sword" + NAME "Wood Sword\0" TYPE SWORD WIDTH HLINE*4 HEIGHT HLINE*10 diff --git a/include/Texture.h b/include/Texture.h index 81a743e..a3f242b 100644 --- a/include/Texture.h +++ b/include/Texture.h @@ -11,7 +11,6 @@ namespace Texture{ class Texturec{ private: - GLuint *image; int texState; public: Texturec(uint amt, ...); @@ -19,6 +18,8 @@ public: void bindPrev(); void bind(int); void walk(); + + GLuint *image; }; #endif //TEXTURE_H diff --git a/include/common.h b/include/common.h index bfd9db6..525a4cd 100644 --- a/include/common.h +++ b/include/common.h @@ -9,6 +9,8 @@ #include <cstdlib> #include <vector> #include <math.h> + #include <thread> + /* * Include GLEW and the SDL 2 headers @@ -60,8 +62,8 @@ typedef struct { #define GAME_NAME "Independent Study v.0.3 alpha" -#define SCREEN_WIDTH 1200 -#define SCREEN_HEIGHT 720 +#define SCREEN_WIDTH 1792 +#define SCREEN_HEIGHT 1008 //#define FULLSCREEN @@ -134,4 +136,9 @@ void DEBUG_prints(const char* file, int line, const char *s,...); void safeSetColor(int r,int g,int b); void safeSetColorA(int r,int g,int b,int a); +unsigned int safe_strlen(const char*); + +void DrawCircle(float cx, float cy, float r, int num_segments); + + #endif // COMMON_H diff --git a/include/entities.h b/include/entities.h index 403c3c5..be5c000 100644 --- a/include/entities.h +++ b/include/entities.h @@ -114,9 +114,12 @@ class Object : public Entity{ public: Object(int); Object(int, bool, char*); - void interact(); + void interact(void); bool questObject = false; char *pickupDialog; + std::thread runInteract() { + return std::thread([=] { interact(); }); + } private: int identifier; }; diff --git a/include/inventory.h b/include/inventory.h index dc5c04e..3fdbf52 100644 --- a/include/inventory.h +++ b/include/inventory.h @@ -2,6 +2,7 @@ #define INVENTORY_H #include <common.h> +#include <string.h> #define DEBUG @@ -19,8 +20,6 @@ * A list of all item IDs. */ -static unsigned int sel; - enum ITEM_ID { DEBUG_ITEM = 69, TEST_ITEM = 1, @@ -49,15 +48,23 @@ public: float height; int maxStackSize; char* textureLoc; + Texturec *tex; 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){ + id(i), type(t), width(w), height(h), maxStackSize(m){ count = 0; + + name = (char*)calloc(strlen(n ),sizeof(char)); + textureLoc = (char*)calloc(strlen(tl),sizeof(char)); + + strcpy(name,n); + strcpy(textureLoc,tl); + + tex= new Texturec(1,textureLoc); } - void addCount(int c){ - count += c; + GLuint rtex(){ + return tex->image[0]; } - }; static Item item[5]= { @@ -66,20 +73,20 @@ static Item item[5]= { struct item_t{ int count; - ITEM_ID itmid; - void addC(int c, ITEM_ID i){ - count = c; - itmid = i; - item[itmid].addCount(count); - } + ITEM_ID id; } __attribute__((packed)); class Inventory { private: unsigned int size; // Size of 'item' array + item_t *inv; + int os = 0; //struct item_t *item; // An array of the items contained in this inventory. public: + unsigned int sel; + bool invOpen = false; + bool invOpening = false; Inventory(unsigned int s); // Creates an inventory of size 's' ~Inventory(void); // Free's 'item' @@ -97,7 +104,6 @@ public: }; -unsigned int initInventorySprites(void); // Loads as many inventory textures as it can find, returns count void itemUse(void *p); #endif // INVENTORY_H @@ -433,9 +433,9 @@ int main(int argc, char *argv[]){ invUI = Texture::loadTexture("assets/invUI.png" ); //std::cout << "Before invSprites\n"; - initInventorySprites(); + //initInventorySprites(); //std::cout << "After invSprites\n"; - + /************************** **** GAMELOOP **** **************************/ @@ -457,12 +457,6 @@ int main(int argc, char *argv[]){ SDL_GL_DeleteContext(mainGLContext); SDL_DestroyWindow(window); - FILE *worldSave = fopen("world.dat","w"); - char *worldBuf; - unsigned int worldSize; - worldBuf=currentWorld->save(&worldSize); - fclose(worldSave); - return 0; // Calls everything passed to atexit } @@ -680,29 +674,8 @@ void render(){ //for length for(int l = 0;l<=lightStr;l++){ //std::cout << a << ": " << curCoord.x << "," << curCoord.y << "\n"; - if(angle == 0){ - curCoord.x += HLINE; - curCoord.y += 0; - } - if(angle == 90){ - curCoord.y += HLINE; - curCoord.x += 0; - } - if(angle == 180){ - curCoord.x -= HLINE; - curCoord.y += 0; - } - if(angle == 270){ - curCoord.y -= HLINE; - curCoord.x += 0; - } - if(angle == 360){ - curCoord.x += HLINE; - curCoord.y += 0; - }else{ - curCoord.x += float((HLINE) * cos(angle*PI/180)); - curCoord.y += float((HLINE) * sin(angle*PI/180)); - } + 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){ @@ -972,7 +945,8 @@ void logic(){ */ if(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT)){ - o->interact(); + std::thread thr(o->runInteract()); + thr.detach(); } } } diff --git a/src/Makefile b/src/Makefile index f40ab90..03652fc 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,4 +1,4 @@ -LIBS = -lGL -lSDL2 -lSDL2_image -lSDL2_mixer -lfreetype +LIBS = -lpthread -lGL -lSDL2 -lSDL2_image -lSDL2_mixer -lfreetype FLAGS = -std=c++11 -I../include -I../include/freetype2 diff --git a/src/Quest.cpp b/src/Quest.cpp index 5fd7726..6789a05 100644 --- a/src/Quest.cpp +++ b/src/Quest.cpp @@ -14,15 +14,6 @@ const Quest QuestList[TOTAL_QUESTS]={ };
-// Trust nobody
-#define STRLEN_MIN 16
-
-unsigned int safe_strlen(const char *s){
- unsigned int size=0;
- while(s[size])size++;
- if(size<STRLEN_MIN)return STRLEN_MIN;
- else return size;
-}
Quest::Quest(const char *t,const char *d,struct item_t r){
title=(char *)calloc(safe_strlen(t),sizeof(char));
@@ -85,7 +76,7 @@ int QuestHandler::finish(const char *t,void *completer){ #ifdef DEBUG
DEBUG_printf("Completing quest %s.\n",t);
#endif // DEBUG
- ((Entity *)completer)->inv->addItem(current[i]->reward.itmid,current[i]->reward.count);
+ ((Entity *)completer)->inv->addItem(current[i]->reward.id,current[i]->reward.count);
current.erase(current.begin()+i);
#ifdef DEBUG
DEBUG_printf("QuestHandler now has %u active quests.\n",current.size());
diff --git a/src/Texture.cpp b/src/Texture.cpp index b17d204..82baa71 100644 --- a/src/Texture.cpp +++ b/src/Texture.cpp @@ -54,7 +54,7 @@ namespace Texture{ SDL_FreeSurface(image); // Free the surface LoadedTexture[LoadedTextureCounter] = (struct texture_t *)malloc(sizeof(struct texture_t)); - LoadedTexture[LoadedTextureCounter]->name = (char *)malloc(strlen(fileName)); + LoadedTexture[LoadedTextureCounter]->name = (char *)malloc(safe_strlen(fileName)); LoadedTexture[LoadedTextureCounter]->tex = object; strcpy(LoadedTexture[LoadedTextureCounter]->name,fileName); LoadedTextureCounter++; diff --git a/src/common.cpp b/src/common.cpp index a8a964e..f3c3999 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -32,3 +32,29 @@ void safeSetColorA(int r,int g,int b,int a){ if(a<0)a=0; glColor4ub(r,g,b,a); } + +//only trust the NSA +#define STRLEN_MIN 32 + +unsigned int safe_strlen(const char *s){ + unsigned int size=0; + while(s[size])size++; + if(size<STRLEN_MIN)return STRLEN_MIN; + else return size; +} + +void DrawCircle(float cx, float cy, float r, int num_segments) +{ + glBegin(GL_LINE_LOOP); + for(int ii = 0; ii < num_segments; ii++) + { + float theta = 2.0f * 3.1415926f * float(ii) / float(num_segments);//get the current angle + + float x = r * cosf(theta);//calculate the x component + float y = r * sinf(theta);//calculate the y component + + glVertex2f(x + cx, y + cy);//output vertex + + } + glEnd(); +}
\ No newline at end of file diff --git a/src/entities.cpp b/src/entities.cpp index af32cd6..c2c560a 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -108,7 +108,7 @@ Object::Object(int id):identifier(id){ height = HLINE * 8; maxHealth = health = 1; - tex = new Texturec(1, "assets/items/ITEM_SWORD.png"); + tex = new Texturec(1, item[id].textureLoc); questObject = false; pickupDialog="\0"; @@ -122,7 +122,7 @@ Object::Object(int id, bool qo, char *pd):identifier(id),questObject(qo),pickupD height = HLINE * 8; maxHealth = health = 1; - tex = new Texturec(1, "assets/items/ITEM_SWORD.png"); + tex = new Texturec(1, item[id].textureLoc); } @@ -316,14 +316,16 @@ void NPC::interact(){ //have the npc's interact back to the player } extern void waitForDialog(void); -void Object::interact(){ +void Object::interact(void){ if(questObject){ - char opt[]=":No:Yes"; + char opt[]=":Yes:No"; ui::dialogBox("You",opt,pickupDialog); - if(ui::dialogOptChosen == 1){ - this->alive = false; - player->inv->addItem((ITEM_ID)(identifier), (char)1); - } + do{ + if(ui::dialogOptChosen == 1 && this->alive == true){ + player->inv->addItem((ITEM_ID)(identifier), (char)1); + this->alive = false; + } + }while(ui::dialogBoxExists); }else{ this->alive = false; player->inv->addItem((ITEM_ID)(identifier), (char)1); diff --git a/src/gameplay.cpp b/src/gameplay.cpp index 52aceb8..6e85b6d 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -162,6 +162,13 @@ void initEverything(void){ currentWorld->addObject(SWORD_WOOD, false, NULL, 500,200); currentWorld->addObject(FLASHLIGHT, true, "This looks important, do you want to pick it up?",600,200); + + /*currentWorld->addObject(DEBUG_ITEM, 500,200); + currentWorld->addObject(TEST_ITEM, 550,200); + currentWorld->addObject(PLAYER_BAG, 600,200); + currentWorld->addObject(SWORD_WOOD, 650,200); + currentWorld->addObject(FLASHLIGHT, true, "This looks important, do you want to pick it up?",700,200); + */ /* * Link all the entities that were just created to the initial world, and setup a test AI function. */ diff --git a/src/inventory.cpp b/src/inventory.cpp index edc88ff..2547760 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -7,26 +7,12 @@ extern Player *player; extern GLuint invUI; -GLuint *ITEM_TEX; - void itemDraw(Player *p,ITEM_ID id); -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[i].textureLoc)))loadCount++; - } -#ifdef DEBUG - DEBUG_printf("Loaded %u/%u item texture(s).\n",loadCount,ITEM_COUNT); -#endif // DEBUG - return loadCount; -} - Inventory::Inventory(unsigned int s){ sel=0; size=s; - //item=(struct item_t *)calloc(size,sizeof(struct item_t)); + inv=(struct item_t *)calloc(size,sizeof(struct item_t)); tossd=false; } @@ -39,43 +25,29 @@ 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,item[i].name); - #endif // DEBUG - - return 0; - }else if(!item[i].count){ - item[i].id=id; - item[i].count=count; + inv[os].id = id; + inv[os].count = count; + os++; - #ifdef DEBUG - DEBUG_printf("Gave player %u %s(s).\n",count,item[i].name); - #endif // DEBUG - return 0; - } - } + #ifdef DEBUG + DEBUG_printf("Gave player %u more %s(s)(%d).\n",count,item[id].name,item[id].id); + #endif // DEBUG -#ifdef DEBUG + /*#ifdef DEBUG DEBUG_printf("Failed to add non-existant item with id %u.\n",id); -#endif // DEBUG - return -1; + #endif // DEBUG*/ + return 0; } int Inventory::takeItem(ITEM_ID id,unsigned char count){ unsigned int i; for(i=0;i<size;i++){ - if(item[i].id==id){ + if(inv[i].id==id){ #ifdef DEBUG DEBUG_printf("Took %u of player's %s(s).\n",count,item[i].name); #endif // DEBUG - item[i].count-=count; + inv[i].count-=count; if(item[i].count<0) return item[i].count*-1; return 0; @@ -85,36 +57,104 @@ int Inventory::takeItem(ITEM_ID id,unsigned char count){ } void Inventory::draw(void){ + ui::putText(offset.x-SCREEN_WIDTH/2,480,"%d",sel); unsigned int i=0; - float y=offset.y,xoff; - 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); + float y,xoff; + + + static int numSlot = 7; + static std::vector<int>dfp(numSlot); + static std::vector<Ray>iray(numSlot); + static std::vector<vec2>curCoord(numSlot); + static int range = 200; + float angleB = (float)180/(float)numSlot; + float angle = float(angleB/2.0f); + unsigned int a = 0; + unsigned int end = 0; + for(auto &r : iray){ + r.start = player->loc; + curCoord[a] = r.start; + //dfp[a] = 0; + a++; + }a=0; + if(invOpening){ + end = 0; + for(auto &d : dfp){ + if(a != 0){ + if(dfp[a-1]>25)d+=25; + }else{ + d += 25; + } + if(d >= range) + d = range; + a++; + }a=0; + if(end < numSlot)invOpen=true; + }else if(!invOpening){ + for(auto &d : dfp){ + if(d > 0){ + if(a != 0){ + //d-=25; + if(dfp[a-1]+25<d || dfp[a-1]<=0)d-=25; + }else{ + d-=25; + } + }else end++; + a++; + }a=0; + if(end >= numSlot)invOpen=false; + } + if(invOpen){ + for(auto &r : iray){ + angle=180-(angleB*a) - angleB/2.0f; + curCoord[a].x += float((dfp[a]) * cos(angle*PI/180)); + curCoord[a].y += float((dfp[a]) * sin(angle*PI/180)); + r.end = curCoord[a]; + + item[inv[i].id].tex->bind(0); + glColor4f(1.0f, 1.0f, 1.0f, (float)dfp[a]/(float)range); + glBegin(GL_QUADS); + glTexCoord2i(0,1);glVertex2i(r.end.x, r.end.y); + glTexCoord2i(1,1);glVertex2i(r.end.x+45, r.end.y); + glTexCoord2i(1,0);glVertex2i(r.end.x+45, r.end.y+45); + glTexCoord2i(0,0);glVertex2i(r.end.x, r.end.y+45); + glEnd(); + a++; + } + } + + + /*else if(!invOpen){ + for(auto &d : dfp){ + d = 0; + } glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D,ITEM_TEX[item[i].id]); - if(sel==i)glColor3ub(255,0,255); - else glColor3ub(255,255,255); + glBindTexture(GL_TEXTURE_2D, invUI); glBegin(GL_QUADS); - glTexCoord2i(0,1);glVertex2i(xoff ,y); - glTexCoord2i(1,1);glVertex2i(xoff+HLINE*10,y); - glTexCoord2i(1,0);glVertex2i(xoff+HLINE*10,y+HLINE*10); - glTexCoord2i(0,0);glVertex2i(xoff ,y+HLINE*10); + 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(); - y-=ui::fontSize*1.15; - ui::putText(offset.x-SCREEN_WIDTH/2,y,"%s",item[i].name); glDisable(GL_TEXTURE_2D); - i++; - } - if(item[sel].count)itemDraw(player,item[sel].id); + while(i<size && inv[i].count > 0 && i<5){ + y = 6; + xoff = (offset.x - (SCREEN_WIDTH /2)) + (51*i) + 6; + glEnable(GL_TEXTURE_2D); + item[inv[i].id].tex->bind(0); + if(sel==i)glColor3ub(255,0,255); + else glColor3ub(255,255,255); + glBegin(GL_QUADS); + glTexCoord2i(0,1);glVertex2i(xoff, y); + glTexCoord2i(1,1);glVertex2i(xoff+45, y); + glTexCoord2i(1,0);glVertex2i(xoff+45, y+45); + glTexCoord2i(0,0);glVertex2i(xoff, y+45); + glEnd(); + glDisable(GL_TEXTURE_2D); + i++; + } + }*/ + if(inv[sel].count)itemDraw(player,inv[sel].id); } static vec2 item_coord = {0,0}; @@ -126,7 +166,7 @@ void itemDraw(Player *p,ITEM_ID id){ static vec2 p1,p2; if(!id)return; glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D,ITEM_TEX[id-1]); + item[id].tex->bind(0); if(!yes){ p1 = {p->loc.x+p->width/2, p->loc.y+p->width/2+HLINE*3}; @@ -134,23 +174,24 @@ void itemDraw(Player *p,ITEM_ID id){ p->loc.y+HLINE*3}; } if(p->inv->tossd) yes=true; + glColor4ub(255,255,255,255); glBegin(GL_QUADS); 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); + glTexCoord2i(1,1);glVertex2f(item_coord.x+item[id].width+p->loc.x, item_coord.y+p->loc.y); + glTexCoord2i(1,0);glVertex2f(item_coord.x+item[id].width+p->loc.x, item_coord.y+item[id].height+p->loc.y); + glTexCoord2i(0,0);glVertex2f(item_coord.x+p->loc.x, item_coord.y+item[id].height+p->loc.y); glEnd(); glDisable(GL_TEXTURE_2D); } int Inventory::useItem(void){ - ITEM_ID id = item[sel].id; + ITEM_ID id = item[inv[sel].id].id; switch(id){ - case SWORD_WOOD: - + case FLASHLIGHT: + player->light ^= true; break; default: - ui::dialogBox(item[id].name,NULL,"You cannot use this item."); + //ui::dialogBox(item[id].name,NULL,"You cannot use this item."); break; } return 0; @@ -527,7 +527,7 @@ DONE: KEYDOWN */ case SDL_KEYDOWN: - if(SDL_KEY==SDLK_ESCAPE)gameRunning=false; // Exit the game with ESC + if(SDL_KEY==SDLK_ESCAPE)gameRunning=false; // Exit the game with ESC if(!dialogBoxExists&&!fadeEnable){ if(SDL_KEY==SDLK_a){ // Move left left=true; @@ -583,17 +583,12 @@ DONE: if(SDL_KEY==SDLK_q){ player->inv->itemToss(); } - if(SDL_KEY==SDLK_e){ - player->inv->useItem(); - } if(SDL_KEY==SDLK_LSHIFT)player->speed = debug?4:3; // Sprint if(SDL_KEY==SDLK_LCTRL)player->speed = .5; } if(SDL_KEY==SDLK_p)toggleBlack(); if(SDL_KEY==SDLK_F3)debug^=true; if(SDL_KEY==SDLK_b & SDL_KEY==SDLK_F3)posFlag^=true; - if(SDL_KEY==SDLK_UP)handAngle++; - if(SDL_KEY==SDLK_DOWN)handAngle--; break; /* KEYUP @@ -606,9 +601,9 @@ DONE: if(SDL_KEY==SDLK_LCTRL)player->speed = 1; if(SDL_KEY==SDLK_h)player->health-=5; if(SDL_KEY==SDLK_f)player->light ^= true; - if(SDL_KEY==SDLK_UP)handAngle+=0; - if(SDL_KEY==SDLK_DOWN)handAngle-=0; - + if(SDL_KEY==SDLK_e)player->inv->invOpening ^= true; + if(SDL_KEY==SDLK_RIGHT){player->inv->sel+=1;} + if(SDL_KEY==SDLK_LEFT){if(player->inv->sel!=0)player->inv->sel-=1;} break; default: break; |