From d6412a6210d4fa25f8c97a98132d27db66ca4514 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Sat, 12 Sep 2015 20:01:45 -0400 Subject: uh --- include/common.h | 5 +++-- src/World.cpp | 16 +++++++++------- src/main.cpp | 49 ++++++++++--------------------------------------- 3 files changed, 22 insertions(+), 48 deletions(-) diff --git a/include/common.h b/include/common.h index 559bfd2..e1b536f 100644 --- a/include/common.h +++ b/include/common.h @@ -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 diff --git a/src/World.cpp b/src/World.cpp index 8f9308e..790a8e0 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -52,13 +52,14 @@ static float drawOffsetX=0, drawOffsetY=0; void World::draw(void){ unsigned int i; - float x,y; + float x,y,hline=HLINE; static World *root,*cur; root=cur=this; LOOP: if(cur->behind){ drawOffsetX+=(cur->getWidth()-cur->behind->getWidth())/2; drawOffsetY+=.3; + hline/=2; cur=cur->behind; goto LOOP; //behind->draw(); @@ -66,18 +67,18 @@ LOOP: LOOP2: glBegin(GL_QUADS); for(i=0;ilineCount-10;i++){ - x=(HLINE*i)-1+drawOffsetX; + x=(hline*i)-1+drawOffsetX; y=cur->line[i].start+drawOffsetY; glColor3ub(0,200,0); glVertex2f(x ,y); - glVertex2f(x+HLINE,y); - y-=HLINE*2; - glVertex2f(x+HLINE,y); + glVertex2f(x+hline,y); + y-=hline*2; + glVertex2f(x+hline,y); glVertex2f(x ,y); glColor3ub(150,100,50); glVertex2f(x ,y); - glVertex2f(x+HLINE,y); - glVertex2f(x+HLINE,-1); + glVertex2f(x+hline,y); + glVertex2f(x+hline,-1); glVertex2f(x ,-1); } glEnd(); @@ -85,6 +86,7 @@ LOOP2: cur=cur->infront; drawOffsetX-=(cur->getWidth()-cur->behind->getWidth())/2; drawOffsetY-=.3; + hline*=2; goto LOOP2; }else{ drawOffsetX=drawOffsetY=0; diff --git a/src/main.cpp b/src/main.cpp index ed82e5e..25d76b5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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(differenceaddLayer(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; -- cgit v1.2.3