From 1a3f4ac5ac12700757d2558ee06f202ad43aa841 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Thu, 10 Sep 2015 15:19:18 -0400 Subject: added linked worlds --- src/World.cpp | 25 ++++++++++++++++++++++++- src/main.cpp | 8 ++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/World.cpp b/src/World.cpp index 022948f..c3a76c7 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -1,6 +1,11 @@ #include -World::World(float width){ +World::World(void){ + line=NULL; + lineCount=0; + toLeft=toRight=NULL; +} +World::World(const float width,World *l,World *r){ unsigned int i; double f; lineCount=width/HLINE+1; @@ -8,6 +13,24 @@ World::World(float width){ std::cout<<"Failed to allocate memory!"<toRight){ + std::cout<<"There's already a world to the left!"<toRight=this; + } + } + if(toRight){ + if(toRight->toLeft){ + std::cout<<"There's already a world to the right!"<toLeft=this; + } + } line[0].start=(rand()%100)/100.0f-0.8f; // lazy if(line[0].start>-0.5f)line[0].start=-0.7f; for(i=10;ispawn(0,0); - World *w=new World(2); + World *w=NULL; + World *w2=new World(4,w,NULL); + w=new World(2,NULL,w2); + currentWorld=w; while(gameRunning){ ui.handleEvents(); // Handle events @@ -75,7 +79,7 @@ int main(int argc,char **argv){ **** RENDER STUFF HERE **** **************************/ - w->draw(); + currentWorld->draw(); glColor3ub(0,0,0); glRectf(player.loc.x, player.loc.y, player.loc.x + player.width, player.loc.y + player.height); -- cgit v1.2.3