]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
uh
authorClyne Sullivan <tullivan99@gmail.com>
Sun, 13 Sep 2015 00:01:45 +0000 (20:01 -0400)
committerClyne Sullivan <tullivan99@gmail.com>
Sun, 13 Sep 2015 00:01:45 +0000 (20:01 -0400)
include/common.h
src/World.cpp
src/main.cpp

index 559bfd26fb50efa78e11a27330b81b7f9dbca8bd..e1b536f0b4ca2a3461cf1fc02f33bb6e0d773cdf 100644 (file)
@@ -20,6 +20,9 @@ typedef struct{float x; float y;}vec2;
 
 #define HLINE (2.0f / (SCREEN_WIDTH / 4))
 
+#define irand srand
+#define grand rand
+
 //SDL VARIABLES
 extern SDL_Window    *window;
 extern SDL_Surface   *renderSurface;
@@ -28,6 +31,4 @@ extern SDL_GLContext  mainGLContext;
 //WINDOW VARIABLES
 extern bool gameRunning;
 
-extern int grand(void);
-
 #endif // COMMON_H
index 8f9308e16b6ab1da622282dcdea0f7527157828e..790a8e09b17fb42a04d0773f2c7e08921c323d89 100644 (file)
@@ -52,13 +52,14 @@ static float drawOffsetX=0,
                         drawOffsetY=0;\r
 void World::draw(void){\r
        unsigned int i;\r
-       float x,y;\r
+       float x,y,hline=HLINE;\r
        static World *root,*cur;\r
        root=cur=this;\r
 LOOP:\r
        if(cur->behind){\r
                drawOffsetX+=(cur->getWidth()-cur->behind->getWidth())/2;\r
                drawOffsetY+=.3;\r
+               hline/=2;\r
                cur=cur->behind;\r
                goto LOOP;\r
                //behind->draw();\r
@@ -66,18 +67,18 @@ LOOP:
 LOOP2:\r
        glBegin(GL_QUADS);\r
                for(i=0;i<cur->lineCount-10;i++){\r
-                       x=(HLINE*i)-1+drawOffsetX;\r
+                       x=(hline*i)-1+drawOffsetX;\r
                        y=cur->line[i].start+drawOffsetY;\r
                        glColor3ub(0,200,0);\r
                        glVertex2f(x      ,y);\r
-                       glVertex2f(x+HLINE,y);\r
-                       y-=HLINE*2;\r
-                       glVertex2f(x+HLINE,y);\r
+                       glVertex2f(x+hline,y);\r
+                       y-=hline*2;\r
+                       glVertex2f(x+hline,y);\r
                        glVertex2f(x      ,y);\r
                        glColor3ub(150,100,50);\r
                        glVertex2f(x      ,y);\r
-                       glVertex2f(x+HLINE,y);\r
-                       glVertex2f(x+HLINE,-1);\r
+                       glVertex2f(x+hline,y);\r
+                       glVertex2f(x+hline,-1);\r
                        glVertex2f(x      ,-1);\r
                }\r
        glEnd();\r
@@ -85,6 +86,7 @@ LOOP2:
                cur=cur->infront;\r
                drawOffsetX-=(cur->getWidth()-cur->behind->getWidth())/2;\r
                drawOffsetY-=.3;\r
+               hline*=2;\r
                goto LOOP2;\r
        }else{\r
                drawOffsetX=drawOffsetY=0;\r
index ed82e5ef76fe1a370dd663e68ea9012234c853fb..25d76b5d3dece5cfda3f937a8521fbef0a42a412 100644 (file)
@@ -16,34 +16,21 @@ static unsigned int tickCount   = 0,
                                        currentTime = 0,
                                        deltaTime   = 0;
 
-Entity *entPlay;       //The player base
-Entity *entnpc;        //The NPC base
-Player player;         //The actual player object
-NPC npc;
-UIClass ui;                    //Yep
-World *currentWorld;//u-huh
-
-//static int randNext=1;
-
-void irand(unsigned int seed){
-       srand(seed);
-}
-
-int grand(void){
-       return rand();
-}
-
-void logic();
+Entity  *entPlay;         //The player base
+Entity  *entnpc;          //The NPC base
+Player  player;                   //The actual player object
+NPC     npc;              // A test NPC
+UIClass ui;                       // Handles the user interface
+World   *currentWorld; // Points to the current 'world' the player is in
 
 float interpolate(float goal, float current, float dt){
-       float difference = goal - current;
-       if(difference > dt){
-               return current + dt;}
-       if(difference < dt){
-               return current - dt;}
+       float difference=goal-current;
+       if(difference>dt)return current+dt;
+       if(difference<dt)return current-dt;
        return goal;
 }
 
+void logic();
 void render();
 
 int main(int argc,char **argv){
@@ -102,22 +89,6 @@ int main(int argc,char **argv){
        currentWorld=w;
        currentWorld->addLayer(3);
        currentWorld->addEntity((void *)entnpc);
-       //currentWorld->addLayer();
-       
-       // Save the world if necessary
-       /*FILE *f=fopen("world.dat","r");
-       unsigned int fSave;
-       if(!f){
-               f=fopen("world.dat","w");
-               if(f){
-                       fSave=time(NULL);
-                       fwrite(&fSave,sizeof(unsigned int),1,f);
-                       fclose(f);
-               }
-       }else{
-               fread(&fSave,sizeof(unsigned int),1,f);
-               fclose(f);
-       }*/
 
        float gw;