From b447a664066e98cc827626526179b3a3db22fa30 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Wed, 2 Dec 2015 08:48:39 -0500 Subject: world bg improvements --- src/world.cpp | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) (limited to 'src/world.cpp') diff --git a/src/world.cpp b/src/world.cpp index c078726..d81d8de 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -18,13 +18,19 @@ bool worldInside = false; // True if player is inside a structure WEATHER weather = SUNNY; -const char *bgPaths[6]={ - "assets/bg.png", // Daytime background +const char *bgPaths[2][6]={ + {"assets/bg.png", // Daytime background "assets/bgn.png", // Nighttime background "assets/bgFarMountain.png", // Furthest layer "assets/forestTileBack.png", // Closer layer "assets/forestTileMid.png", // Near layer - "assets/forestTileFront.png" // Closest layer + "assets/forestTileFront.png"}, // Closest layer + {"assets/bgWoodTile.png", + NULL, + NULL, + NULL, + NULL, + NULL} }; const float bgDraw[3][3]={ @@ -45,14 +51,11 @@ float worldGetYBase(World *w){ void World::setBackground(WORLD_BG_TYPE bgt){ switch(bgt){ - default: - bgTex = new Texturec(6,bgPaths[0], - bgPaths[1], - bgPaths[2], - bgPaths[3], - bgPaths[4], - bgPaths[5] - ); + case BG_FOREST: + bgTex = new Texturec(6,bgPaths[0]); + break; + case BG_WOODHOUSE: + bgTex = new Texturec(1,bgPaths[1]); break; } } @@ -768,7 +771,7 @@ void World::addMob(int t,float x,float y){ entity.push_back(mob.back()); } -void World::addMob(int t,float x,float y,void (*hey)()){ +void World::addMob(int t,float x,float y,void (*hey)(Mob *)){ mob.push_back(new Mob(t)); mob.back()->spawn(x,y); mob.back()->hey = hey; @@ -910,13 +913,27 @@ void IndoorWorld::generate(unsigned int width){ // Generates a flat area of wid void IndoorWorld::draw(Player *p){ int i,ie,v_offset; + glEnable(GL_TEXTURE_2D); + bgTex->bind(0); + glColor4ub(255,255,255,255); + glBegin(GL_QUADS); + for(i = x_start - SCREEN_WIDTH / 2;i < -x_start + SCREEN_WIDTH / 2; i += 1024){ + glTexCoord2i(1,1);glVertex2i(i ,0); + glTexCoord2i(0,1);glVertex2i(i+1024,0); + glTexCoord2i(0,0);glVertex2i(i+1024,1024); + glTexCoord2i(1,0);glVertex2i(i ,1024); + } + glEnd(); + glDisable(GL_TEXTURE_2D); + v_offset=(p->loc.x-x_start)/HLINE; // Calculate the player's offset in the array 'line' using the player's location 'vec' i=v_offset-SCREEN_WIDTH/2; // um if(i<0)i=0; // If the player is past the start of that world 'i' should start at the beginning // of the world ie=v_offset+SCREEN_WIDTH/2; // Set how many lines should be drawn (the drawing for loop loops from 'i' to 'ie') if(ie>lineCount)ie=lineCount; // If the player is past the end of that world 'ie' should contain the end of that world - glClearColor(.3,.1,0,0); + //glClearColor(.3,.1,0,0); + glBegin(GL_QUADS); for(i=i;i Date: Thu, 3 Dec 2015 07:26:22 -0500 Subject: exit fixes, faster dialog --- src/entities.cpp | 8 +++++--- src/ui.cpp | 16 ++++++++++++++-- src/world.cpp | 6 ++---- 3 files changed, 21 insertions(+), 9 deletions(-) (limited to 'src/world.cpp') diff --git a/src/entities.cpp b/src/entities.cpp index 9c5e3cb..f0e7d16 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -120,11 +120,13 @@ Structures::Structures(){ //sets the structure type tex = new Texturec(1,"assets/house1.png"); inWorld = NULL; + name = NULL; } Structures::~Structures(){ - delete inv; + //delete inv; delete tex; - delete[] name; + if(name) + delete[] name; } Mob::Mob(int sub){ @@ -177,7 +179,7 @@ Object::Object(ITEM_ID id, bool qo, const char *pd){ Object::~Object(){ delete[] pickupDialog; - delete inv; + //delete inv; delete tex; delete[] name; } diff --git a/src/ui.cpp b/src/ui.cpp index e10ed46..f01dab8 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -48,6 +48,7 @@ static char *dialogBoxText = NULL; static char *dialogOptText[4]; static float dialogOptLoc[4][3]; static unsigned char dialogOptCount = 0; +static bool typeOutDone = true; extern void mainLoop(void); @@ -318,18 +319,23 @@ namespace ui { size=strlen(str); // Set the new target string size linc=0; // Reset the incrementers sinc=1; + typeOutDone = false; } /* * Draw the next letter if necessary. */ - if(++sinc==2){ + if(typeOutDone) + return str; + else if(++sinc==2){ sinc=0; strncpy(ret+linc,str+linc,1); // Get next character - if(linc dialogOptLoc[i][0] && mouse.x < dialogOptLoc[i][2] && diff --git a/src/world.cpp b/src/world.cpp index d81d8de..3557121 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -95,11 +95,9 @@ void World::deleteEntities(void){ } World::~World(void){ - - if(behind){ + if(behind) delete behind; - } - + delete bgTex; delete[] star; delete[] line; -- cgit v1.2.3