diff options
-rw-r--r-- | assets/names_en-us | 3 | ||||
-rw-r--r-- | config/quest_list.txt | 2 | ||||
-rw-r--r-- | include/inventory.h | 1 | ||||
-rw-r--r-- | main.cpp | 5 | ||||
-rw-r--r-- | src/entities.cpp | 5 | ||||
-rw-r--r-- | src/gameplay.cpp | 1 | ||||
-rw-r--r-- | src/inventory.cpp | 50 | ||||
-rw-r--r-- | src/ui.cpp | 18 |
8 files changed, 55 insertions, 30 deletions
diff --git a/assets/names_en-us b/assets/names_en-us index 2d1f8d9..c65808b 100644 --- a/assets/names_en-us +++ b/assets/names_en-us @@ -105,4 +105,5 @@ fSylvia fStarla fMonserrate fAnn -fAshley
\ No newline at end of file +fAshley +fAbby Ross
\ No newline at end of file diff --git a/config/quest_list.txt b/config/quest_list.txt index 3014ede..484a2cc 100644 --- a/config/quest_list.txt +++ b/config/quest_list.txt @@ -1 +1 @@ -TITLE "Test" DESC "A test quest" REWARD 1 x TEST_ITEM END +TITLE "Test" DESC "A test quest" REWARD 1 x SWORD_WOOD END diff --git a/include/inventory.h b/include/inventory.h index b62e491..18ef6c4 100644 --- a/include/inventory.h +++ b/include/inventory.h @@ -73,6 +73,7 @@ public: unsigned int sel; bool invOpen = false; bool invOpening = false; + bool invHover = false; Inventory(unsigned int s); // Creates an inventory of size 's' ~Inventory(void); // Free's allocated memory @@ -504,7 +504,6 @@ void mainLoop(void){ */ ui::handleEvents(); - if(prevPrevTime + MSEC_PER_TICK <= currentTime){ logic(); prevPrevTime = currentTime; @@ -529,7 +528,7 @@ void mainLoop(void){ debugY = player->loc.y; } - render(); // Call the render loop + render(); // Call the render loop; } extern bool fadeEnable; @@ -951,8 +950,10 @@ void logic(){ o->interact(); objectInteracting=false; } + } } + } } } diff --git a/src/entities.cpp b/src/entities.cpp index 3286784..ee5a542 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -122,7 +122,6 @@ Structures::Structures(){ //sets the structure type inWorld = NULL; } Structures::~Structures(){ - delete inv; delete tex; delete[] name; } @@ -177,7 +176,6 @@ Object::Object(ITEM_ID id, bool qo, const char *pd){ Object::~Object(){ delete[] pickupDialog; - delete inv; delete tex; delete[] name; } @@ -339,7 +337,8 @@ void NPC::interact(){ //have the npc's interact back to the player } } -void Object::interact(void){ + +void Object::interact(void){ if(questObject && alive){ ui::dialogBox("You",":Yes:No",pickupDialog); ui::waitForDialog(); diff --git a/src/gameplay.cpp b/src/gameplay.cpp index 64b3908..6a2036c 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -108,6 +108,7 @@ void initEverything(void){ playerSpawnHill->addStructure(STRUCTURET,(rand()%120*HLINE),10,test,iw); playerSpawnHill->addMob(MS_TRIGGER,-1300,0,CUTSCENEEE); + playerSpawnHill->addObject(SWORD_WOOD, false, "", 480,200); playerSpawnHill->addObject(SWORD_WOOD, false, "", 500,200); playerSpawnHill->addObject(FLASHLIGHT, true, "This looks important, do you want to pick it up?",600,200); diff --git a/src/inventory.cpp b/src/inventory.cpp index a365204..73e5e32 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -55,18 +55,21 @@ void Inventory::setSelection(unsigned int s){ } int Inventory::addItem(ITEM_ID id,unsigned char count){ - inv[os].id = id; - inv[os].count = count; - os++; + std::cout << id << "," << inv[os].id << std::endl; + for(int i = 0; i < size; i++){ + if(id == inv[i].id){ + inv[i].count += count; + break; + }else if(id ){ + inv[os].id = id; + inv[os].count = count; + os++; + break; + } + } #ifdef DEBUG DEBUG_printf("Gave player %u more %s(s)(ID: %d).\n",count,item[id].name,item[id].id); #endif // DEBUG - - -/*#ifdef DEBUG - DEBUG_printf("Failed to add non-existant item with id %u.\n",id); -#endif // DEBUG*/ - return 0; } @@ -87,7 +90,7 @@ int Inventory::takeItem(ITEM_ID id,unsigned char count){ } void Inventory::draw(void){ - ui::putText(offset.x-SCREEN_WIDTH/2,480,"%d",sel); + std::cout << invHover << std::endl; unsigned int i=0; static unsigned int lop = 0; float y,xoff; @@ -96,12 +99,14 @@ void Inventory::draw(void){ static std::vector<Ray>iray(numSlot); static std::vector<vec2>curCoord(numSlot); static int range = 200; + static int itemWide = 45; 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; + 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++; @@ -127,32 +132,33 @@ void Inventory::draw(void){ } if(end >= numSlot)invOpen=false; } - if(invOpen){ + if(invOpen || invHover){ 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]; - glColor4f(0.0f, 0.0f, 0.0f, ((float)dfp[a]/(float)range)*0.3f); + glColor4f(0.0f, 0.0f, 0.0f, ((float)dfp[a]/(float)range)*invHover ? 0.2f : 0.5f); glBegin(GL_QUADS); - glVertex2i(r.end.x, r.end.y); - glVertex2i(r.end.x+45, r.end.y); - glVertex2i(r.end.x+45, r.end.y+45); - glVertex2i(r.end.x, r.end.y+45); + 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); glEnd(); if(inv[a].count > 0){ glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, itemtex[inv[a].id]); - glColor4f(1.0f, 1.0f, 1.0f, (float)dfp[a]/(float)range); + glColor4f(1.0f, 1.0f, 1.0f, ((float)dfp[a]/(float)range)*invHover ? 0.5f : 1.0f); 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); + 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); 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++; } @@ -516,6 +516,7 @@ namespace ui { void handleEvents(void){ static bool left=false,right=false; static vec2 premouse={0,0}; + static int heyOhLetsGo = 0; unsigned char i; SDL_Event e; @@ -611,6 +612,13 @@ DONE: 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_e){ + if(heyOhLetsGo == 0){ + heyOhLetsGo = loops; + }else if(loops - heyOhLetsGo >= 5 && !(player->inv->invOpen)){ + player->inv->invHover=true; + } + } break; /* KEYUP @@ -623,7 +631,15 @@ 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_e)player->inv->invOpening ^= true; + if(SDL_KEY==SDLK_e){ + if(player->inv->invHover){ + player->inv->invHover = false; + heyOhLetsGo = 0; + }else{ + player->inv->invOpening ^= true; + heyOhLetsGo = 0; + } + } if(SDL_KEY==SDLK_RIGHT){player->inv->sel+=1;} if(SDL_KEY==SDLK_LEFT){if(player->inv->sel!=0)player->inv->sel-=1;} break; |