From: drumsetmonkey Date: Mon, 30 Nov 2015 13:49:20 +0000 (-0500) Subject: Working on animations X-Git-Url: https://code.bitgloo.com/?a=commitdiff_plain;h=af22d85f9a417a94ea75db1878219f8baeba8b73;p=clyne%2Fgamedev.git Working on animations --- af22d85f9a417a94ea75db1878219f8baeba8b73 diff --cc include/common.h index 869c811,0ddb5e4..50ba316 --- a/include/common.h +++ b/include/common.h @@@ -117,16 -116,6 +116,8 @@@ extern vec2 offset extern float handAngle; - /* - * Loads an image from the given file path and attempts to make a texture out of it. The - * resulting GLuint is returned (used to recall the texture in glBindTexture). - * - */ - - extern unsigned int loops; - - //GLuint loadTexture(const char *fileName); ++extern unsigned int loops; + /* * Prints a formatted debug message to the console, along with the callee's file and line * number. diff --cc include/inventory.h index 3b4c260,a9a4bcb..2b402fc --- a/include/inventory.h +++ b/include/inventory.h @@@ -50,21 -49,8 +50,10 @@@ public int maxStackSize; char* textureLoc; Texturec *tex; + GLuint text; int count; - Item(ITEM_ID i, char* n, ITEM_TYPE t, float w, float h, int m, char* tl): - id(i), type(t), width(w), height(h), maxStackSize(m){ - count = 0; + - name = (char*)calloc(strlen(n )+1,sizeof(char)); - textureLoc = (char*)calloc(strlen(tl)+1,sizeof(char)); - - strcpy(name,n); - strcpy(textureLoc,tl); - - tex= new Texturec(1,textureLoc); - text = Texture::loadTexture(textureLoc); - } + Item(ITEM_ID i, const char *n, ITEM_TYPE t, float w, float h, int m, const char *tl); GLuint rtex(){ return tex->image[0]; } diff --cc src/entities.cpp index c2c560a,4e582c9..1681efd --- a/src/entities.cpp +++ b/src/entities.cpp @@@ -100,21 -100,13 +100,14 @@@ Mob::Mob(int sub) inv = new Inventory(NPC_INV_SIZE); } - Object::Object(int id):identifier(id){ - type = OBJECTT; - alive = true; - near = false; - width = HLINE * 8; - height = HLINE * 8; - - maxHealth = health = 1; - tex = new Texturec(1, item[id].textureLoc); - - questObject = false; - pickupDialog="\0"; - } + Object::Object(ITEM_ID id, bool qo, const char *pd){ + identifier = id; + questObject = qo; + + pickupDialog = new char[strlen(pd)+1]; + strcpy(pickupDialog,pd); + + - Object::Object(int id, bool qo, char *pd):identifier(id),questObject(qo),pickupDialog(pd){ type = OBJECTT; alive = true; near = false; @@@ -122,7 -114,7 +115,8 @@@ height = HLINE * 8; maxHealth = health = 1; - tex = new Texturec(1, item[id].textureLoc); + tex = new Texturec(1,getItemTexturePath(id)); ++ } diff --cc src/inventory.cpp index ed22fb6,cd01c11..3b2663b --- a/src/inventory.cpp +++ b/src/inventory.cpp @@@ -7,8 -7,33 +7,29 @@@ extern Player *player; extern GLuint invUI; -static Item item[5]= { - #include "../config/items.h" -}; - void itemDraw(Player *p,ITEM_ID id); + char *getItemTexturePath(ITEM_ID id){ + return item[id].textureLoc; + } + + Item::Item(ITEM_ID i, const char *n, ITEM_TYPE t, float w, float h, int m, const char *tl){ + id = i; + type = t; + width = w; + height = h; + maxStackSize = m; + count = 0; + + name = new char[strlen(n)+1]; //(char*)calloc(strlen(n ),sizeof(char)); + textureLoc = new char[strlen(tl)+1]; //(char*)calloc(strlen(tl),sizeof(char)); + + strcpy(name,n); + strcpy(textureLoc,tl); + + tex= new Texturec(1,textureLoc); + } + Inventory::Inventory(unsigned int s){ sel=0; size=s; @@@ -59,10 -86,7 +82,8 @@@ int Inventory::takeItem(ITEM_ID id,unsi void Inventory::draw(void){ ui::putText(offset.x-SCREEN_WIDTH/2,480,"%d",sel); unsigned int i=0; + static unsigned int lop = 0; float y,xoff; - - static int numSlot = 7; static std::vectordfp(numSlot); static std::vectoriray(numSlot); @@@ -159,8 -179,8 +180,9 @@@ i++; } }*/ + if(inv[sel].count)itemDraw(player,inv[sel].id); + lop++; } static vec2 item_coord = {0,0};