- 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
#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
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
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:
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)
};
**************************/
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);
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;
}
Inventory::Inventory(unsigned int s){
+ sel=0;
size=s;
item=(struct item_t *)calloc(size,sizeof(struct item_t));
}
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;
}
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);
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