]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
improved layers
authorClyne Sullivan <tullivan99@gmail.com>
Sat, 12 Sep 2015 02:58:02 +0000 (22:58 -0400)
committerClyne Sullivan <tullivan99@gmail.com>
Sat, 12 Sep 2015 02:58:02 +0000 (22:58 -0400)
include/World.h
src/World.cpp
src/main.cpp

index 91eb81e8bca3eca0c4065e4b33ad31a0060df936..13ccafcabd5c924357dc1bc2d075e9ef31305649 100644 (file)
@@ -6,7 +6,7 @@
 #define goWorldLeft(w)  if(w->toLeft){w=w->toLeft;}\r
 #define goWorldRight(w) if(w->toRight){w=w->toRight;}\r
 \r
-#define LAYER_SCALE 1\r
+#define LAYER_SCALE 2\r
 \r
 class World {\r
 private:\r
@@ -15,7 +15,7 @@ private:
                double start; // Where to change to dirt, going down (y)\r
        } __attribute__ ((packed)) *line;\r
        unsigned int lineCount;\r
-       bool root;\r
+       bool root,drawn;\r
 public:\r
        World *behind,*infront;\r
        World *toLeft,*toRight;\r
index 6b1b317359eb20c91e0ddc65ca2e4c1ebb120590..f6bb70eecccd8c7e3be1a1c39fb33cec7c5e0adc 100644 (file)
@@ -54,13 +54,19 @@ static float back=0;
 void World::draw(void){\r
        unsigned int i;\r
        if(behind){\r
-               hline/=1.5;\r
+               hline*=.5;\r
                back+=.2;\r
                behind->draw();\r
+       }else{\r
+               hline*=.5;\r
+               back+=.2;\r
        }\r
        if(root){\r
                hline=HLINE;\r
                back=0;\r
+       }else{\r
+               hline*=2;\r
+               back-=.2;\r
        }\r
        glBegin(GL_QUADS);\r
                for(i=0;i<lineCount-10;i++){\r
index 8768edd99e60cc9de30315eed86fd5bd2e6d95dc..51b5c070356fb230641c3239abec343131aab69c 100644 (file)
@@ -93,8 +93,10 @@ int main(int argc,char **argv){
        w=new World(2,NULL,w2);
        
        currentWorld=w;
-       currentWorld->addLayer();
        currentWorld->setRoot();
+       currentWorld->addLayer();
+       //currentWorld->addLayer();
+       //currentWorld->addLayer();
        
        // Save the world if necessary
        /*FILE *f=fopen("world.dat","r");
@@ -172,7 +174,7 @@ void render(){
                **** RENDER STUFF HERE ****
                **************************/
                 
-               currentWorld->draw();
+               currentWorld->draw(); // layers dont scale x correctly...
                glColor3ub(120,30,30);
                glRectf(player.loci.x, player.loci.y, player.loci.x + player.width, player.loci.y + player.height);