From: drumsetmonkey Date: Mon, 21 Mar 2016 12:17:06 +0000 (-0400) Subject: Created currency and new inventory X-Git-Url: https://code.bitgloo.com/?a=commitdiff_plain;h=51c6e601c3d6451294506b72213244e3aee9822f;p=clyne%2Fgamedev.git Created currency and new inventory --- 51c6e601c3d6451294506b72213244e3aee9822f diff --cc include/ui.h index a4fed3e,072d418..2a7518f --- a/include/ui.h +++ b/include/ui.h @@@ -129,9 -126,7 +129,8 @@@ namespace ui void setFontFace(const char *ttf); void setFontSize(unsigned int size); + void setFontColor(unsigned char r,unsigned char g,unsigned char b, unsigned char a); - /* * Draw a centered string. */ @@@ -153,9 -148,10 +152,10 @@@ void dialogBox(const char *name,const char *opt,bool passive,const char *text,...); void merchantBox(const char *name,Trade trade,const char *opt,bool passive,const char *text,...); void merchantBox(); + void closeBox(); void waitForDialog(void); + void drawPage( std::string path ); - /* * Draws a larger string in the center of the screen. Drawing is done inside this function. */ diff --cc main.cpp index 411a8c5,69aab76..e7494a9 --- a/main.cpp +++ b/main.cpp @@@ -415,9 -415,9 +415,8 @@@ int main(int argc, char *argv[]) //currentWorld->mob.back()->followee = player; gameRunning = true; - while(gameRunning){ - - while ( gameRunning ) -- mainLoop(); - } ++ ++ while(gameRunning)mainLoop(); /************************** **** CLOSE PROGRAM **** @@@ -492,15 -492,7 +491,14 @@@ void mainLoop(void) prevPrevTime = currentTime; } + /* + * Update player and entity coordinates. + */ + + /*pool.Enqueue([](){ + currentWorld->update(player,deltaTime); + });*/ - - currentWorld->update(player,deltaTime); + currentWorld->update( player, deltaTime ); /* * Update debug variables if necessary @@@ -789,8 -781,8 +787,7 @@@ void logic() for(int r = 0; r < (rand()%30)+15;r++) currentWorld->addParticle(rand()%HLINE*3 + n->loc.x - .05f,n->loc.y + n->height*.5, HLINE,HLINE, -(rand()%10)*.01,((rand()%10)*.01-.05), {(rand()%75)+10/100.0f,0,0}, 10000); } - }*/ - + } - /* * Don't bother handling the NPC if another has already been handled. */ diff --cc src/ui.cpp index 3b3f298,f69bfe8..245f1d7 --- a/src/ui.cpp +++ b/src/ui.cpp @@@ -124,9 -126,7 +126,8 @@@ namespace ui int dialogPassiveTime = 0; Trade merchTrade; + int fontTransInv = 255; - /* * Dialog stuff that needs to be 'public'. */ @@@ -333,10 -321,10 +332,10 @@@ * Loop on each character: */ - do { + do{ if(i && ((i / 110.0) == (i / 110))){ - yo-=fontSize*1.05; - xo=x; + o.y -= fontSize * 1.05f; + o.x = x; if(s[i] == ' ') i++; } @@@ -373,19 -369,22 +380,21 @@@ unsigned int i = 0; float width = 0; - do{ - if(s[i]=='\n'){ // Handle newlines + do { + switch ( s[i] ) { + case '\n': // TODO - }else if(s[i]==' '){ // Handle spaces - width+=fontSize/2; - }else if(s[i]=='\b'){ // Handle backspaces? - // Why? - // Cuz - }else{ - width+=ftexwh[i].x+fontSize*.1; + break; + case '\b': + break; + case ' ': + width += fontSize / 2; + break; + default: + width += ftexwh[i].x + fontSize * 0.1f; + break; } - }while(s[++i]); - + } while(s[++i]); - putString(floor(x-width/2),y,s); return width; } @@@ -1223,13 -1210,15 +1234,20 @@@ fclose(bmp); } + void closeBox(){ + dialogBoxExists = false; + dialogMerchant = false; + } + void dialogAdvance(void){ unsigned char i; + + if ( pageTex ) { + glDeleteTextures( 1, &pageTex ); + pageTex = 0; + return; + } + if(!typeOutDone){ typeOutDone = true; return; diff --cc src/world.cpp index c31f551,dec9a64..b1eb12e --- a/src/world.cpp +++ b/src/world.cpp @@@ -220,10 -218,7 +218,6 @@@ World: Mix_FreeMusic(bgmObj); delete bgTex; - - delete[] toLeft; - delete[] toRight; -- deleteEntities(); } @@@ -772,16 -772,22 +771,21 @@@ singleDetect( Entity *e if ( e->loc.y < worldData[i].groundHeight ) { - e->loc.y= worldData[i].groundHeight - .001 * deltaTime; - e->ground=true; - e->vel.y=0; - if ( worldData[i].groundHeight - e->loc.y > 30 ) { - int dir = e->vel.x > 0 ? -1 : 1; - e->loc.x += HLINE * 8 * dir; - e->loc.y = worldData[i + 8 * dir].groundHeight; - } else { - e->loc.y = worldData[i].groundHeight - .001 * deltaTime; - e->ground = true; - e->vel.y = 0; - } ++ if ( worldData[i].groundHeight - e->loc.y > 30 ) { ++ int dir = e->vel.x > 0 ? -1 : 1; ++ e->loc.x += HLINE * 8 * dir; ++ e->loc.y = worldData[i + 8 * dir].groundHeight; ++ } else { ++ e->loc.y = worldData[i].groundHeight - .001 * deltaTime; ++ e->ground = true; ++ e->vel.y = 0; ++ } /* * Handle gravity if the entity is above the line. */ - } else { - + }else{ - if(e->type == STRUCTURET && e->loc.y > 2000){ e->loc.y = worldData[i].groundHeight; e->vel.y = 0; @@@ -969,26 -976,18 +974,19 @@@ void World::addLight(vec2 loc, Color co } } - char *World::setToLeft(const char *file){ - if(toLeft) - delete[] toLeft; - if(!file) - return (toLeft = NULL); - - strcpy((toLeft = new char[strlen(file) + 1]),file); - return toLeft; + std::string World:: + setToLeft( std::string file ) + { + return (toLeft = file); } - char *World::setToRight(const char *file){ - if(toRight) - delete[] toRight; - if(!file) - return (toRight = NULL); - - strcpy((toRight = new char[strlen(file) + 1]),file); - return toRight; + + std::string World:: + setToRight( std::string file ) + { + return (toRight = file); } +//what is this clyne why are they differnet World *World:: goWorldLeft( Player *p ) { @@@ -1107,14 -1133,10 +1132,12 @@@ void World::save(void) data.append(std::to_string((int)m->alive) + "\n"); } - std::cout << "Ending file" << std::endl; data.append("dOnE\0"); + std::cout << "Writing to the file" << std::endl; out.write(data.c_str(),data.size()); - std::cout << "Closing file" << std::endl; out.close(); + std::cout << "Done saving" << std::endl; } void World::load(void){