]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
background draw re-do
authorClyne Sullivan <tullivan99@gmail.com>
Fri, 20 Nov 2015 13:50:57 +0000 (08:50 -0500)
committerClyne Sullivan <tullivan99@gmail.com>
Fri, 20 Nov 2015 13:50:57 +0000 (08:50 -0500)
15 files changed:
Changelog
assets/BennyHillTheme.wav
assets/forestTileBack.png [new file with mode: 0644]
assets/forestTileFront.png [new file with mode: 0644]
assets/forestTileMid.png [new file with mode: 0644]
include/Texture.h
include/world.h
main.cpp
src/Texture.cpp
src/gameplay.cpp
src/ui.cpp
src/world.cpp
xcf/forestTileBack.xcf [new file with mode: 0644]
xcf/forestTileFront.xcf [new file with mode: 0644]
xcf/forestTileMid.xcf [new file with mode: 0644]

index 0fe938603bbd347477408acd0e1ea90dad118a9f..50e8f44570f5547e929cb7e8dfa4b397f6d6f46c 100644 (file)
--- a/Changelog
+++ b/Changelog
        - converted layered background items to tiles
        - fixed ortho in small spaces
        - began formalizing item system
+
+11/19/2015:
+===========
+
+       - texture loaded tracks loaded textures to prevent re-loading (frees resources)
+       - continued work on things finished the following day (11/20) :)
+       
+11/20/2015:
+===========
+
+       - began working on inventory UI
+       - moved background drawing to World class
+       - re-did the item system
+       - actually tiled background images to save space
index 34c455b083382a4de4a81510c194a3e5c01ae8da..a9269026804c14664f140610e1704d77f76b78a1 100644 (file)
Binary files a/assets/BennyHillTheme.wav and b/assets/BennyHillTheme.wav differ
diff --git a/assets/forestTileBack.png b/assets/forestTileBack.png
new file mode 100644 (file)
index 0000000..0ea6022
Binary files /dev/null and b/assets/forestTileBack.png differ
diff --git a/assets/forestTileFront.png b/assets/forestTileFront.png
new file mode 100644 (file)
index 0000000..e54f631
Binary files /dev/null and b/assets/forestTileFront.png differ
diff --git a/assets/forestTileMid.png b/assets/forestTileMid.png
new file mode 100644 (file)
index 0000000..b23afd2
Binary files /dev/null and b/assets/forestTileMid.png differ
index fdb294dd7a198cb1350f655c64c0430e8bbda2fd..81a743eaa4da84bbbe0373cf6fae43b5abe46a5a 100644 (file)
@@ -3,23 +3,22 @@
 
 #include <common.h>
 
+#define DEBUG
+
 namespace Texture{
        GLuint loadTexture(const char *fileName);
 }
 
 class Texturec{
+private:
+       GLuint *image;
+       int texState;
 public:
        Texturec(uint amt, ...);
        void bindNext();
        void bindPrev();
        void bind(int);
        void walk();
-
-       GLuint *image;
-       int texState;
-private:
-
-
 };
 
-#endif //TEXTURE_H
\ No newline at end of file
+#endif //TEXTURE_H
index 8f4ea5152b416a5efe65551b2a8b162d7ef0682e..1a96252f7764c2d951d8ae73836d3a044e263446 100644 (file)
@@ -9,6 +9,18 @@
                                                // or not calculated at all, so GEN_INC is also used to decrease 'lineCount' in functions like draw()
                                                // and detect().
 
+#define DAY_CYCLE 3000
+
+typedef enum {
+       BG_FOREST
+} WORLD_BG_TYPE;
+
+typedef enum {
+       SUNNY = 0,
+       DARK,
+       RAIN
+} WEATHER;
+
 struct line_t {
        bool gs;
        float y,gh[2];
@@ -56,6 +68,14 @@ protected:
        
        unsigned int lineCount;
        
+       /*
+        *      Contains the background image layers (including the background image).
+       */
+       
+       vec2 *star;
+       
+       Texturec *bgTex;
+       
 public:
 
        /*
@@ -78,16 +98,11 @@ public:
        std::vector<Entity              *>      entity;
        std::vector<Object              *>      object;
        
-       //template<class T>
-       //void getEntityLocation(std::vector<T*>&, unsigned int);
-       
        void addStructure(_TYPE t,float x,float y,World *outside,World *inside);
        void addMob(int t,float x,float y);
        void addMob(int t,float x,float y,void (*hey)());
        void addNPC(float x,float y);
        void addObject(int, float, float);
-
-       //void removeObjet(Object);
        
        void update(Player *p,unsigned int delta);
        
@@ -106,6 +121,12 @@ public:
        virtual void generate(unsigned int width);
        void generateFunc(unsigned int width,float(*func)(float));
        
+       /*
+        *      Adds images to using for the background.
+       */
+       
+       void setBackground(WORLD_BG_TYPE bgt);
+       
        /*
         *      Looks for the furthest back layer in this world and adds a new layer of width `width` behind it.
        */
index 1f8c58e6ee0a53cb7e24534e128ccbb464cb8ffb..a26222afe15783c96dd9f2d87d50d3f0801f1871 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -208,17 +208,7 @@ unsigned int millis(void){
 }
 #endif
 
-typedef enum {
-       SUNNY = 0,
-       DARK,
-       RAIN
-} WEATHER;
-
-#define DAY_CYCLE 3000
-
-static WEATHER weather = SUNNY;
-static vec2 star[100];
-
+extern WEATHER weather;
 
 /*******************************************************************************
  * MAIN ************************************************************************
@@ -434,12 +424,12 @@ int main(int argc, char *argv[]){
         *      Load a temporary background image.
        */
        
-       bgDay            =Texture::loadTexture("assets/bg.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"       );
+       bgTreesFar       =Texture::loadTexture("assets/bgFarTreeTile.png"       );*/
        
        /*
         *      Load sprites used in the inventory menu. See src/inventory.cpp
@@ -447,16 +437,6 @@ int main(int argc, char *argv[]){
        
        initInventorySprites();
        
-       /*
-        *      Generate coordinates for stars that are drawn at night.
-       */
-       
-       unsigned int i;
-       for(i=0;i<100;i++){
-               star[i].x=getRand()%currentWorld->getTheWidth()-currentWorld->getTheWidth()/2;
-               star[i].y=getRand()%SCREEN_HEIGHT+100;
-       }
-       
        /**************************
        ****     GAMELOOP      ****
        **************************/
@@ -647,113 +627,9 @@ void render(){
        /**************************
        **** RENDER STUFF HERE ****
        **************************/
-
-       /*
-        *  Draw a temporary background image
-       */
-
-       glEnable(GL_TEXTURE_2D);
-       glBindTexture(GL_TEXTURE_2D,bgDay);
-       safeSetColorA(255,255,255,255-worldShade*4);
-       glBegin(GL_QUADS);
-               glTexCoord2i(0,1);glVertex2i(-SCREEN_WIDTH*2+offset.x,0+offset.y-SCREEN_HEIGHT/2);
-               glTexCoord2i(1,1);glVertex2i( SCREEN_WIDTH*2+offset.x,0+offset.y-SCREEN_HEIGHT/2);
-               glTexCoord2i(1,0);glVertex2i( SCREEN_WIDTH*2+offset.x,SCREEN_HEIGHT*2+offset.y-SCREEN_HEIGHT/2);
-               glTexCoord2i(0,0);glVertex2i(-SCREEN_WIDTH*2+offset.x,SCREEN_HEIGHT*2+offset.y-SCREEN_HEIGHT/2);
-       glEnd();
-       glBindTexture(GL_TEXTURE_2D,bgNight);
-       safeSetColorA(255,255,255,worldShade*4);
-       glBegin(GL_QUADS);
-               glTexCoord2i(0,1);glVertex2i(-SCREEN_WIDTH*2+offset.x,0+offset.y-SCREEN_HEIGHT/2);
-               glTexCoord2i(1,1);glVertex2i( SCREEN_WIDTH*2+offset.x,0+offset.y-SCREEN_HEIGHT/2);
-               glTexCoord2i(1,0);glVertex2i( SCREEN_WIDTH*2+offset.x,SCREEN_HEIGHT*2+offset.y-SCREEN_HEIGHT/2);
-               glTexCoord2i(0,0);glVertex2i(-SCREEN_WIDTH*2+offset.x,SCREEN_HEIGHT*2+offset.y-SCREEN_HEIGHT/2);
-       glEnd();
-
-       glDisable(GL_TEXTURE_2D);
-
-       /*
-        *      Draws stars if it is an appropriate time of day for them.
-       */
-
-       int base = 80;
-       int shade = worldShade*2;
-
-       if(((weather==DARK )&(tickCount%DAY_CYCLE)<DAY_CYCLE/2)   ||
-          ((weather==SUNNY)&(tickCount%DAY_CYCLE)>DAY_CYCLE*.75) ){
-                  
-               if(tickCount%DAY_CYCLE){        // The above if statement doesn't check for exact midnight.
-                               
-                       safeSetColorA(255,255,255,shade);
-                       for(unsigned int i=0;i<100;i++){
-                               glRectf(star[i].x+offset.x*.9,star[i].y,star[i].x+offset.x*.9+HLINE,star[i].y+HLINE);
-                       }
-                       
-               }
-       }
-
-       /*
-        *      Calculate the Y to start drawing the background at, and a value for how shaded the
-        *      background elements should be. 
-       */
-
-       glEnable(GL_TEXTURE_2D);
-
-       /*
-        *      Draw the mountains.
-       */
-
-       glBindTexture(GL_TEXTURE_2D, bgMtn);
-       glBegin(GL_QUADS);
-       safeSetColorA(150-shade,150-shade,150-shade,220);
-       for(int i = 0; i <= currentWorld->getTheWidth()/1920; i++){
-               glTexCoord2i(0,1);glVertex2i((currentWorld->getTheWidth()*-0.5f)+(1920 * i)+offset.x*.85,base);
-               glTexCoord2i(1,1);glVertex2i((currentWorld->getTheWidth()*-0.5f)+(1920 * (i+1))+offset.x*.85,base);
-               glTexCoord2i(1,0);glVertex2i((currentWorld->getTheWidth()*-0.5f)+(1920 * (i+1))+offset.x*.85,base+1080);
-               glTexCoord2i(0,0);glVertex2i((currentWorld->getTheWidth()*-0.5f)+(1920 * i)+offset.x*.85,base+1080);
-       }
-       glEnd();
-
-       /*
-        *      Draw three layers of trees.
-       */
-
-       glBindTexture(GL_TEXTURE_2D, bgTreesFar);
-       glBegin(GL_QUADS);
-       safeSetColorA(100-shade,100-shade,100-shade,240);
-       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 = -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 = -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);
-       
+               
        /*
-        *      Call the world's draw function, drawing the player, the world, and entities. Also
+        *      Call the world's draw function, drawing the player, the world, the background, and entities. Also
         *      draw the player's inventory if it exists.
        */
 
index 01a19aa4a3590695e738b8da2f7645cb848e5cb9..b17d20445b5c51a47baa66b7a17af094955b1aa1 100644 (file)
@@ -1,34 +1,64 @@
 #include <Texture.h>
+#include <string.h>
+
+struct texture_t {
+       char *name;
+       GLuint tex;
+} __attribute__ ((packed));
+
+struct texture_t *LoadedTexture[256];
+unsigned int LoadedTextureCounter = 0;
 
 namespace Texture{
        GLuint loadTexture(const char *fileName){
-               SDL_Surface *image = IMG_Load(fileName);
+               SDL_Surface *image;
+               GLuint object = 0;
+               unsigned int i;
 
-               if(!image)return 0;
-               DEBUG_printf("Loaded image file: %s\n", fileName);
-               unsigned object = 0; //creates a new unsigned variable for the texture
+               for(unsigned int i=0;i<LoadedTextureCounter;i++){
+                       if(!strcmp(LoadedTexture[i]->name,fileName)){
+#ifdef DEBUG
+                               DEBUG_printf("Reusing loaded texture for %s\n",fileName);
+#endif // DEBUG
+                               return LoadedTexture[i]->tex;
+                       }
+               }
 
-               glGenTextures(1, &object); //turns "object" into a texture
-               glBindTexture(GL_TEXTURE_2D, object); //binds "object" to the top of the stack
-               glPixelStoref(GL_UNPACK_ALIGNMENT,1 );
+               if(!(image = IMG_Load(fileName)))
+                       return 0;
+#ifdef DEBUG
+               DEBUG_printf("Loaded image file: %s\n", fileName);
+#endif // DEBUG
+               
+               glGenTextures(1,&object);                               // Turns "object" into a texture
+               glBindTexture(GL_TEXTURE_2D,object);    // Binds "object" to the top of the stack
+               glPixelStoref(GL_UNPACK_ALIGNMENT,1);
 
-               glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); //sets the "min" filter
-               glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); //the the "max" filter of the stack
+               glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);       // Sets the "min" filter
+               glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);       // The the "max" filter of the stack
 
-               glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); //Wrap the texture to the matrix
-               glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); //Wrap the texutre to the matrix
+               glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); // Wrap the texture to the matrix
+               glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); //
 
-               glTexImage2D(   GL_TEXTURE_2D, 
-                                               0, 
-                                           GL_RGBA,
-                                           image->w,
-                                           image->h, 
-                                           0, 
-                                           GL_RGBA, 
-                                           GL_UNSIGNED_BYTE, 
-                                           image->pixels); //sets the texture to the image file loaded above
+               glTexImage2D(GL_TEXTURE_2D,  // Sets the texture to the image file loaded above
+                                        0, 
+                                        GL_RGBA,
+                                        image->w,
+                                        image->h, 
+                                        0, 
+                                        GL_RGBA, 
+                                        GL_UNSIGNED_BYTE, 
+                                        image->pixels
+                                        );
 
-               SDL_FreeSurface(image); //Free surface
+               SDL_FreeSurface(image); // Free the surface
+               
+               LoadedTexture[LoadedTextureCounter]               = (struct texture_t *)malloc(sizeof(struct texture_t));
+               LoadedTexture[LoadedTextureCounter]->name = (char *)malloc(strlen(fileName));
+               LoadedTexture[LoadedTextureCounter]->tex  = object;
+               strcpy(LoadedTexture[LoadedTextureCounter]->name,fileName);
+               LoadedTextureCounter++;
+               
                return object;
        }
 }
@@ -58,5 +88,5 @@ void Texturec::bindPrev(){
 }
 
 void Texturec::walk(){
-       
-}
\ No newline at end of file
+       // hey
+}
index e5d7251f053c6990750d9e4ca772cce3d737ae98..1d9fac6e1db143e06672f4600f7e8f20d3587614 100644 (file)
@@ -91,9 +91,11 @@ void initEverything(void){
                test->addHole(100,150);
        //}
        
+       test->setBackground(BG_FOREST);
        test->addLayer(400);
        
        playerSpawnHill->generateFunc(1280,playerSpawnHillFunc);
+       playerSpawnHill->setBackground(BG_FOREST);
        //playerSpawnHill->generate(1920);
 
        /*
index e4cb93a0318bc3b105eec42174b92c651cc76412..1ea844c3dde4406580facef7349e839ffdd39268 100644 (file)
@@ -455,8 +455,8 @@ namespace ui {
                                }else setFontColor(255,255,255);
                                dialogOptLoc[i][1]=y-SCREEN_HEIGHT/4+(fontSize+HLINE)*(i+1);
                                dialogOptLoc[i][2]=
-                               putStringCentered(player->loc.x,dialogOptLoc[i][1],dialogOptText[i]);
-                               dialogOptLoc[i][0]=player->loc.x-dialogOptLoc[i][2]/2;
+                               putStringCentered(offset.x,dialogOptLoc[i][1],dialogOptText[i]);
+                               dialogOptLoc[i][0]=offset.x-dialogOptLoc[i][2]/2;
                        }
                        setFontColor(255,255,255);
                }
index 904bed76eb897eaa0b5c0f43b3ce4c5f8a754ad2..44d1900ee55f777dd002d6cc146c1d24a3ae9e09 100644 (file)
@@ -6,15 +6,32 @@
 #define GEN_MAX  110
 #define GEN_INIT 60
 
-#define GRASS_HEIGHT 4         // Defines how long the grass layer of a line should be in multiples of HLINE.
+#define GRASS_HEIGHT 4                         // Defines how long the grass layer of a line should be in multiples of HLINE.
 
 
-#define DRAW_Y_OFFSET 50       // Defines how many pixels each layer should be offset from each other on the y axis when drawn.
-#define DRAW_SHADE       30    // Defines a shade increment for draw()
+#define DRAW_Y_OFFSET 50               // Defines how many pixels each layer should be offset from each other on the y axis when drawn.
+#define DRAW_SHADE       30            // Defines a shade increment for draw()
 
 #define INDOOR_FLOOR_HEIGHT 100 // Defines how high the base floor of an IndoorWorld should be
 
-bool worldInside = false;
+bool worldInside = false;              // True if player is inside a structure
+
+WEATHER weather = SUNNY;
+
+const char *bgPaths[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
+};
+
+const float bgDraw[3][3]={
+       {100,240,.6 },
+       {150,250,.4 },
+       {255,255,.25}
+};
 
 float worldGetYBase(World *w){
        /*float base = 0;
@@ -54,6 +71,20 @@ void World::load(char *buf){
        memcpy(line,buf+sizeof(struct wSavePack),lineCount * sizeof(struct line_t));
 }
 
+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]
+                                                          );
+               break;
+       }
+}
+
 World::World(void){
        /*
         *      Nullify pointers to other worlds.
@@ -63,6 +94,8 @@ World::World(void){
        infront =
        toLeft  =
        toRight = NULL;
+       
+       star = (vec2 *)calloc(100,sizeof(vec2));
 }
 
 void World::generate(unsigned int width){      // Generates the world and sets all variables contained in the World class.
@@ -159,6 +192,11 @@ void World::generate(unsigned int width){  // Generates the world and sets all va
        */
        
        x_start=0 - getWidth(this) / 2;
+       
+       for(int i=0;i<100;i++){
+               star[i].x=getRand()%getTheWidth()-getTheWidth()/2;
+               star[i].y=getRand()%SCREEN_HEIGHT+100;
+       }
 }
 
 void World::generateFunc(unsigned int width,float(*func)(float)){
@@ -176,6 +214,11 @@ void World::generateFunc(unsigned int width,float(*func)(float)){
                line[i].gs=true;
        }
        x_start=0 - getWidth(this) / 2;
+       
+       for(int i=0;i<100;i++){
+               star[i].x=getRand()%getTheWidth()-getTheWidth()/2;
+               star[i].y=getRand()%SCREEN_HEIGHT+100;
+       }
 }
 
 World::~World(void){
@@ -197,13 +240,105 @@ void World::update(Player *p,unsigned int delta){
 
 int worldShade = 0;
 
+extern vec2 offset;
+extern unsigned int tickCount;
+
 void World::draw(Player *p){
        static float yoff=DRAW_Y_OFFSET;        // Initialize stuff
-       static int shade;
+       static int shade,bgshade;
        static World *current;
-       int i,is,ie,v_offset,cx_start;
+       int i,is,ie,v_offset,cx_start,width;
        struct line_t *cline;
-       glClearColor(.1,.3,.6,0);
+       
+       bgshade = worldShade << 1; // *2
+       width = (-x_start) << 1;
+       
+       /*
+        *      Draw the background images in the appropriate order.
+       */
+       
+       glEnable(GL_TEXTURE_2D);
+       
+       bgTex->bind(0);
+       safeSetColorA(255,255,255,255 - worldShade * 4);
+       
+       glBegin(GL_QUADS);
+               glTexCoord2i(0,0);glVertex2i( x_start,SCREEN_HEIGHT);
+               glTexCoord2i(1,0);glVertex2i(-x_start,SCREEN_HEIGHT);
+               glTexCoord2i(1,1);glVertex2i(-x_start,0);
+               glTexCoord2i(0,1);glVertex2i( x_start,0);
+       glEnd();
+       
+       bgTex->bindNext();
+       safeSetColorA(255,255,255,worldShade * 4);
+       
+       glBegin(GL_QUADS);
+               glTexCoord2i(0,0);glVertex2i( x_start,SCREEN_HEIGHT);
+               glTexCoord2i(1,0);glVertex2i(-x_start,SCREEN_HEIGHT);
+               glTexCoord2i(1,1);glVertex2i(-x_start,0);
+               glTexCoord2i(0,1);glVertex2i( x_start,0);
+       glEnd();
+
+       glDisable(GL_TEXTURE_2D);
+
+       /*
+        *      Draws stars if it is an appropriate time of day for them.
+       */
+
+       if(((weather==DARK )&(tickCount%DAY_CYCLE)<DAY_CYCLE/2)   ||
+          ((weather==SUNNY)&(tickCount%DAY_CYCLE)>DAY_CYCLE*.75) ){
+                  
+               if(tickCount % DAY_CYCLE){      // The above if statement doesn't check for exact midnight.
+                               
+                       safeSetColorA(255,255,255,bgshade + getRand() % 30 - 15);
+                       for(i = 0; i < 100; i++){
+                               glRectf(star[i].x+offset.x*.9,
+                                               star[i].y,
+                                               star[i].x+offset.x*.9+HLINE,
+                                               star[i].y+HLINE
+                                               );
+                       }
+                       
+               }
+       }
+       
+       glEnable(GL_TEXTURE_2D);
+
+       /*
+        *      Draw the mountains.
+       */
+
+       bgTex->bindNext();
+       safeSetColorA(150-bgshade,150-bgshade,150-bgshade,220);
+       
+       glBegin(GL_QUADS);
+               for(int i = 0; i <= width/1920; i++){
+                       glTexCoord2i(0,1);glVertex2i(width/-2+(1920*i    )+offset.x*.85,GEN_MIN);
+                       glTexCoord2i(1,1);glVertex2i(width/-2+(1920*(i+1))+offset.x*.85,GEN_MIN);
+                       glTexCoord2i(1,0);glVertex2i(width/-2+(1920*(i+1))+offset.x*.85,GEN_MIN+1080);
+                       glTexCoord2i(0,0);glVertex2i(width/-2+(1920*i    )+offset.x*.85,GEN_MIN+1080);
+               }
+       glEnd();
+       
+       /*
+        *      Draw three layers of trees.
+       */
+
+       for(i = 0; i < 3; i++){
+               bgTex->bindNext();
+               safeSetColorA(bgDraw[i][0]-bgshade,bgDraw[i][0]-bgshade,bgDraw[i][0]-bgshade,bgDraw[i][1]);
+       
+               glBegin(GL_QUADS);
+                       for(int j = x_start; j <= -x_start; j += 600){
+                               glTexCoord2i(0,1);glVertex2i( j     +offset.x*bgDraw[i][2],GEN_MIN);
+                               glTexCoord2i(1,1);glVertex2i((j+600)+offset.x*bgDraw[i][2],GEN_MIN);
+                               glTexCoord2i(1,0);glVertex2i((j+600)+offset.x*bgDraw[i][2],GEN_MIN+400);
+                               glTexCoord2i(0,0);glVertex2i( j     +offset.x*bgDraw[i][2],GEN_MIN+400);
+                       }
+               glEnd();
+       }
+       
+       glDisable(GL_TEXTURE_2D);
        
        /*
         *      World drawing is done recursively, meaning that this function jumps
diff --git a/xcf/forestTileBack.xcf b/xcf/forestTileBack.xcf
new file mode 100644 (file)
index 0000000..723912f
Binary files /dev/null and b/xcf/forestTileBack.xcf differ
diff --git a/xcf/forestTileFront.xcf b/xcf/forestTileFront.xcf
new file mode 100644 (file)
index 0000000..f7bf8f4
Binary files /dev/null and b/xcf/forestTileFront.xcf differ
diff --git a/xcf/forestTileMid.xcf b/xcf/forestTileMid.xcf
new file mode 100644 (file)
index 0000000..0b719dc
Binary files /dev/null and b/xcf/forestTileMid.xcf differ