diff options
-rw-r--r-- | Changelog | 8 | ||||
-rw-r--r-- | include/common.h | 4 | ||||
-rw-r--r-- | include/inventory.h | 5 | ||||
-rw-r--r-- | main.cpp | 4 | ||||
-rw-r--r-- | src/inventory.cpp | 18 | ||||
-rw-r--r-- | src/world.cpp | 2 |
6 files changed, 34 insertions, 7 deletions
@@ -95,3 +95,11 @@ - added running textures to player - added crouching - improved world draw, world now draws player as well + +10/9/2015: +========== + + - improved player inventory + - improved quests + - added mobs + - added DEBUG flags and functions to inventory.cpp and ui.cpp diff --git a/include/common.h b/include/common.h index b7c13e7..b57999d 100644 --- a/include/common.h +++ b/include/common.h @@ -30,8 +30,8 @@ enum GENDER{ #include <Quest.h> #include <entities.h> -#define SCREEN_WIDTH 1280 -#define SCREEN_HEIGHT 740 +#define SCREEN_WIDTH 640 +#define SCREEN_HEIGHT 480 //#define FULLSCREEN #define HLINE 3 //base unit of the world diff --git a/include/inventory.h b/include/inventory.h index d68fed9..c477b8e 100644 --- a/include/inventory.h +++ b/include/inventory.h @@ -7,7 +7,7 @@ enum ITEM_ID { // Contains item IDs for every item in the game, this is how items are stored. IDs are also used to lookup item strings TEST_ITEM = 1, // A test item (duh) - SWORD_ITEM + SWORD_ITEM = 2 }; struct item_t { // Used to define entries in an entity's inventory @@ -17,6 +17,7 @@ struct item_t { // Used to define entries in an entity's inventory 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. public: @@ -26,6 +27,8 @@ public: int addItem(ITEM_ID id,unsigned char count); // Add 'count' items with an id of 'id' to the inventory int takeItem(ITEM_ID id,unsigned char count); // Take 'count' items with an id of 'id' from the inventory + void setSelection(unsigned int s); + void draw(void); // Draws a text list of items in this inventory (should only be called for the player for now) }; @@ -218,7 +218,7 @@ void render(){ **************************/ mx = ui::mouse.x + player->loc.x; my = ui::mouse.y; - my = 720 - my; + my = SCREEN_HEIGHT - my; mx -= (SCREEN_WIDTH/2); glColor3ub(255,255,255); glBegin(GL_TRIANGLES); @@ -243,7 +243,7 @@ void logic(){ entity[i]->near=true; if(SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(SDL_BUTTON_RIGHT)){ entity[i]->interact(); - std::cout <<"["<<i<<"] -> "<< entity[i]->name << ", " << (std::string)(entity[i]->gender == MALE ? "Male" : "Female") << std::endl; + //std::cout <<"["<<i<<"] -> "<< entity[i]->name << ", " << (std::string)(entity[i]->gender == MALE ? "Male" : "Female") << std::endl; //Mix_PlayChannel( -1, horn, 0); } }else entity[i]->near=false; diff --git a/src/inventory.cpp b/src/inventory.cpp index 3882fb0..83c40f6 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -30,6 +30,7 @@ unsigned int initInventorySprites(void){ } Inventory::Inventory(unsigned int s){ + sel=0; size=s; item=(struct item_t *)calloc(size,sizeof(struct item_t)); } @@ -37,19 +38,32 @@ Inventory::Inventory(unsigned int s){ Inventory::~Inventory(void){ free(item); } - + +void Inventory::setSelection(unsigned int s){ + sel=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[i]); +#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[i]); +#endif // DEBUG return 0; } } +#ifdef DEBUG + DEBUG_printf("Failed to add non-existant item with id %u.\n",id); +#endif // DEBUG return -1; } @@ -78,6 +92,8 @@ void Inventory::draw(void){ xoff=ui::putText(player->loc.x-SCREEN_WIDTH/2,y,"%d x ",item[i].count); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,ITEM_TEX[item[i].id-1]); + 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+HLINE*10,y); diff --git a/src/world.cpp b/src/world.cpp index 72287be..1498016 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -163,7 +163,7 @@ void World::singleDetect(Entity *e){ e->ground=true; e->loc.y=line[i].y-.001*deltaTime; if(e->type==STRUCTURET){ - std::cout<<e->loc.x<<" "<<e->loc.y<<std::endl; + //std::cout<<e->loc.x<<" "<<e->loc.y<<std::endl; return; } }else if(e->loc.y>line[i].y-.002*deltaTime){ // Snap the player to the top of that line if the player is inside it |