\r
#include <common.h>\r
\r
-#define HLINE (2.0f/(SCREEN_WIDTH/4))\r
+#define goWorldLeft(w) if(w->toLeft){w=w->toLeft;}\r
+#define goWorldRight(w) if(w->toRight){w=w->toRight;}\r
\r
class World {\r
private:\r
} *line;\r
unsigned int lineCount;\r
public:\r
- World(float width);\r
+ World *toLeft,*toRight;\r
+ World(void);\r
+ World(const float width,World *l,World *r);\r
void draw(void);\r
void detect(vec2 *v,const float width);\r
};\r
#define SCREEN_HEIGHT 800\r
#define FULLSCREEN\r
\r
-\r
+#define HLINE (2.0f/(SCREEN_WIDTH/4))\r
\r
//SDL VARIABLES\r
extern SDL_Window *window;\r
#include <World.h>\r
\r
-World::World(float width){\r
+World::World(void){\r
+ line=NULL;\r
+ lineCount=0;\r
+ toLeft=toRight=NULL;\r
+}\r
+World::World(const float width,World *l,World *r){\r
unsigned int i;\r
double f;\r
lineCount=width/HLINE+1;\r
std::cout<<"Failed to allocate memory!"<<std::endl;\r
abort();\r
}\r
+ toLeft=l;\r
+ toRight=r;\r
+ if(toLeft){\r
+ if(toLeft->toRight){\r
+ std::cout<<"There's already a world to the left!"<<std::endl;\r
+ abort();\r
+ }else{\r
+ toLeft->toRight=this;\r
+ }\r
+ }\r
+ if(toRight){\r
+ if(toRight->toLeft){\r
+ std::cout<<"There's already a world to the right!"<<std::endl;\r
+ abort();\r
+ }else{\r
+ toRight->toLeft=this;\r
+ }\r
+ }\r
line[0].start=(rand()%100)/100.0f-0.8f; // lazy\r
if(line[0].start>-0.5f)line[0].start=-0.7f;\r
for(i=10;i<lineCount;i+=10){ \r
UIClass ui;\r
Entities *entit1;\r
Player player;\r
+World *currentWorld;\r
\r
int main(int argc,char **argv){\r
// Initialize SDL\r
entit1 = &player;\r
entit1->spawn(0,0);\r
\r
- World *w=new World(2);\r
+ World *w=NULL;\r
+ World *w2=new World(4,w,NULL);\r
+ w=new World(2,NULL,w2);\r
+ currentWorld=w;\r
\r
while(gameRunning){\r
ui.handleEvents(); // Handle events\r
**** RENDER STUFF HERE ****\r
**************************/\r
\r
- w->draw();\r
+ currentWorld->draw();\r
glColor3ub(0,0,0);\r
glRectf(player.loc.x, player.loc.y, player.loc.x + player.width, player.loc.y + player.height);\r
\r