aboutsummaryrefslogtreecommitdiffstats
path: root/main.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2015-11-18 08:49:51 -0500
committerClyne Sullivan <tullivan99@gmail.com>2015-11-18 08:49:51 -0500
commit5598e4d1f52224f2d075dc318868e284b2f20a78 (patch)
tree10078c443ebe1b9dd048e0bea04999097dad0e90 /main.cpp
parentfcf3e396c57b285b621624f63f9acd6515c58ef9 (diff)
tiled backgrounds, ortho fix
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp48
1 files changed, 25 insertions, 23 deletions
diff --git a/main.cpp b/main.cpp
index 62cd87a..1f8c58e 100644
--- a/main.cpp
+++ b/main.cpp
@@ -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);