diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2015-11-18 08:49:51 -0500 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2015-11-18 08:49:51 -0500 |
commit | 5598e4d1f52224f2d075dc318868e284b2f20a78 (patch) | |
tree | 10078c443ebe1b9dd048e0bea04999097dad0e90 /main.cpp | |
parent | fcf3e396c57b285b621624f63f9acd6515c58ef9 (diff) |
tiled backgrounds, ortho fix
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 48 |
1 files changed, 25 insertions, 23 deletions
@@ -434,12 +434,12 @@ int main(int argc, char *argv[]){ * Load a temporary background image. */ - bgDay =Texture::loadTexture("assets/bg.png" ); - bgNight =Texture::loadTexture("assets/bgn.png" ); - bgMtn =Texture::loadTexture("assets/bgFarMountain.png"); - bgTreesFront =Texture::loadTexture("assets/bgFrontTree.png" ); - bgTreesMid =Texture::loadTexture("assets/bgMidTree.png" ); - bgTreesFar =Texture::loadTexture("assets/bgFarTree.png" ); + bgDay =Texture::loadTexture("assets/bg.png" ); + bgNight =Texture::loadTexture("assets/bgn.png" ); + bgMtn =Texture::loadTexture("assets/bgFarMountain.png" ); + bgTreesFront =Texture::loadTexture("assets/bgFrontTreeTile.png" ); + bgTreesMid =Texture::loadTexture("assets/bgMidTreeTile.png" ); + bgTreesFar =Texture::loadTexture("assets/bgFarTreeTile.png" ); /* * Load sprites used in the inventory menu. See src/inventory.cpp @@ -572,7 +572,9 @@ void render(){ * see past the world render */ - if(!worldInside){ + if(currentWorld->getTheWidth() < SCREEN_WIDTH){ + offset.x = 0; + }else if(!worldInside){ if(player->loc.x - SCREEN_WIDTH/2 < currentWorld->getTheWidth() * -0.5f) offset.x = ((currentWorld->getTheWidth() * -0.5f) + SCREEN_WIDTH / 2) + player->width / 2; if(player->loc.x + player->width + SCREEN_WIDTH/2 > currentWorld->getTheWidth() * 0.5f) @@ -674,7 +676,7 @@ void render(){ * Draws stars if it is an appropriate time of day for them. */ - int base = 40 - (int)worldGetYBase(currentWorld); + int base = 80; int shade = worldShade*2; if(((weather==DARK )&(tickCount%DAY_CYCLE)<DAY_CYCLE/2) || @@ -719,33 +721,33 @@ void render(){ glBindTexture(GL_TEXTURE_2D, bgTreesFar); glBegin(GL_QUADS); safeSetColorA(100-shade,100-shade,100-shade,240); - for(int i = 0; i <= currentWorld->getTheWidth()/1920; i++){ - glTexCoord2i(0,1);glVertex2i((currentWorld->getTheWidth()*-0.5f)+(1920 * i)+offset.x*.6,base); - glTexCoord2i(1,1);glVertex2i((currentWorld->getTheWidth()*-0.5f)+(1920 * (i+1))+offset.x*.6,base); - glTexCoord2i(1,0);glVertex2i((currentWorld->getTheWidth()*-0.5f)+(1920 * (i+1))+offset.x*.6,base+1080); - glTexCoord2i(0,0);glVertex2i((currentWorld->getTheWidth()*-0.5f)+(1920 * i)+offset.x*.6,base+1080); + for(int i = -currentWorld->getTheWidth() / 2; i <= currentWorld->getTheWidth() / 2; i += 300){ + glTexCoord2i(0,1);glVertex2i(i+offset.x*.6,base); + glTexCoord2i(1,1);glVertex2i((i+300)+offset.x*.6,base); + glTexCoord2i(1,0);glVertex2i((i+300)+offset.x*.6,base+200); + glTexCoord2i(0,0);glVertex2i(i+offset.x*.6,base+200); } glEnd(); glBindTexture(GL_TEXTURE_2D, bgTreesMid); glBegin(GL_QUADS); safeSetColorA(150-shade,150-shade,150-shade,250); - for(int i = 0; i <= currentWorld->getTheWidth()/1920; i++){ - glTexCoord2i(0,1);glVertex2i((currentWorld->getTheWidth()*-0.5f)+(1920 * i)+offset.x*.4,base); - glTexCoord2i(1,1);glVertex2i((currentWorld->getTheWidth()*-0.5f)+(1920 * (i+1))+offset.x*.4,base); - glTexCoord2i(1,0);glVertex2i((currentWorld->getTheWidth()*-0.5f)+(1920 * (i+1))+offset.x*.4,base+1080); - glTexCoord2i(0,0);glVertex2i((currentWorld->getTheWidth()*-0.5f)+(1920 * i)+offset.x*.4,base+1080); + for(int i = -currentWorld->getTheWidth() / 2; i <= currentWorld->getTheWidth() / 2; i += 400){ + glTexCoord2i(0,1);glVertex2i(i+offset.x*.4,base); + glTexCoord2i(1,1);glVertex2i((i+300)+offset.x*.4,base); + glTexCoord2i(1,0);glVertex2i((i+300)+offset.x*.4,base+200); + glTexCoord2i(0,0);glVertex2i(i+offset.x*.4,base+200); } glEnd(); glBindTexture(GL_TEXTURE_2D, bgTreesFront); glBegin(GL_QUADS); safeSetColorA(255-shade,255-shade,255-shade,255); - for(int i = 0; i <= currentWorld->getTheWidth()/1920; i++){ - glTexCoord2i(0,1);glVertex2i((currentWorld->getTheWidth()*-0.5f)+(1920 * i)+offset.x*.25,base); - glTexCoord2i(1,1);glVertex2i((currentWorld->getTheWidth()*-0.5f)+(1920 * (i+1))+offset.x*.25,base); - glTexCoord2i(1,0);glVertex2i((currentWorld->getTheWidth()*-0.5f)+(1920 * (i+1))+offset.x*.25,base+1080); - glTexCoord2i(0,0);glVertex2i((currentWorld->getTheWidth()*-0.5f)+(1920 * i)+offset.x*.25,base+1080); + for(int i = -currentWorld->getTheWidth() / 2; i <= currentWorld->getTheWidth() / 2; i += 280){ + glTexCoord2i(0,1);glVertex2i(i+offset.x*.25,base); + glTexCoord2i(1,1);glVertex2i((i+300)+offset.x*.25,base); + glTexCoord2i(1,0);glVertex2i((i+300)+offset.x*.25,base+200); + glTexCoord2i(0,0);glVertex2i(i+offset.x*.25,base+200); } glEnd(); glDisable(GL_TEXTURE_2D); |