From 6c2fa9e1b372f71d311b376e689961dad6aaa036 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Fri, 18 Sep 2015 17:26:28 -0400 Subject: forgot stuff --- src/world.cpp | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/world.cpp (limited to 'src/world.cpp') diff --git a/src/world.cpp b/src/world.cpp new file mode 100644 index 0000000..d2a15f7 --- /dev/null +++ b/src/world.cpp @@ -0,0 +1,73 @@ +#include + +#define getWidth() (lineCount*HLINE) + +#define GEN_INC 10 +#define GRASS_HEIGHT 4 + +World::World(unsigned int width){ + unsigned int i; + float inc; + lineCount=width+GEN_INC; + line=(struct line_t *)calloc(lineCount,sizeof(struct line_t)); // allocate space for the array of lines + line[0].y=80; + for(i=GEN_INC;i110)line[i].y=110; + } + for(i=0;ix-x_start)/HLINE; + i=v_offset-SCREEN_WIDTH/2; + if(i<0)i=0; + ie=v_offset+SCREEN_WIDTH/2; + if(ie>lineCount)ie=lineCount; + glBegin(GL_QUADS); + for(i=i;ix+width/2-x_start)/HLINE; + if(v->y<=line[i].y){ + vel->y=0; + v->y=line[i].y+HLINE/2; + return; + }else{ + vel->y-=.05; + return; + } +} -- cgit v1.2.3