]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
tiled backgrounds, ortho fix
authorClyne Sullivan <tullivan99@gmail.com>
Wed, 18 Nov 2015 13:49:51 +0000 (08:49 -0500)
committerClyne Sullivan <tullivan99@gmail.com>
Wed, 18 Nov 2015 13:49:51 +0000 (08:49 -0500)
Changelog
assets/bgFarTreeTile.png [new file with mode: 0644]
assets/bgFrontTreeTile.png [new file with mode: 0644]
assets/bgMidTreeTile.png [new file with mode: 0644]
assets/bgTrashWaves.png [new file with mode: 0644]
main.cpp
src/world.cpp
xcf/bgTrashWaves.xcf [new file with mode: 0644]

index 1a75022354323ff63ca90e4377885889af553b1c..0fe938603bbd347477408acd0e1ea90dad118a9f 100644 (file)
--- a/Changelog
+++ b/Changelog
        - added entity deletion when an entity dies
        - fixed errors with typewriter-text
        - finished cutscene triggers
+
+11/18/2015:
+===========
+
+       - converted layered background items to tiles
+       - fixed ortho in small spaces
+       - began formalizing item system
diff --git a/assets/bgFarTreeTile.png b/assets/bgFarTreeTile.png
new file mode 100644 (file)
index 0000000..07546a5
Binary files /dev/null and b/assets/bgFarTreeTile.png differ
diff --git a/assets/bgFrontTreeTile.png b/assets/bgFrontTreeTile.png
new file mode 100644 (file)
index 0000000..7fc7450
Binary files /dev/null and b/assets/bgFrontTreeTile.png differ
diff --git a/assets/bgMidTreeTile.png b/assets/bgMidTreeTile.png
new file mode 100644 (file)
index 0000000..126723e
Binary files /dev/null and b/assets/bgMidTreeTile.png differ
diff --git a/assets/bgTrashWaves.png b/assets/bgTrashWaves.png
new file mode 100644 (file)
index 0000000..6a177cd
Binary files /dev/null and b/assets/bgTrashWaves.png differ
index 62cd87a6678ee23b01f06ba5bee9c790ca9898b8..1f8c58e6ee0a53cb7e24534e128ccbb464cb8ffb 100644 (file)
--- 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);
index 335bda662891ea2dbad11ad31efd4cca305676fe..904bed76eb897eaa0b5c0f43b3ce4c5f8a754ad2 100644 (file)
 bool worldInside = false;
 
 float worldGetYBase(World *w){
-       float base = 0;
+       /*float base = 0;
        World *ptr = w;
        while(ptr->infront){
                base+=DRAW_Y_OFFSET;
                ptr=ptr->infront;
-       }
-       return base;
+       }*/
+       return /*base*/ GEN_MIN;
 }
 
 struct wSavePack {
diff --git a/xcf/bgTrashWaves.xcf b/xcf/bgTrashWaves.xcf
new file mode 100644 (file)
index 0000000..0214d8d
Binary files /dev/null and b/xcf/bgTrashWaves.xcf differ