aboutsummaryrefslogtreecommitdiffstats
path: root/src/World.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2015-09-10 15:19:18 -0400
committerClyne Sullivan <tullivan99@gmail.com>2015-09-10 15:19:18 -0400
commit1a3f4ac5ac12700757d2558ee06f202ad43aa841 (patch)
treec4df6844f422b7506b611311933d6568f4fd538b /src/World.cpp
parenta3db993224c994fdff6f50fedcc266c5e0b94aa8 (diff)
added linked worlds
Diffstat (limited to 'src/World.cpp')
-rw-r--r--src/World.cpp25
1 files changed, 24 insertions, 1 deletions
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.h>
-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!"<<std::endl;
abort();
}
+ toLeft=l;
+ toRight=r;
+ if(toLeft){
+ if(toLeft->toRight){
+ std::cout<<"There's already a world to the left!"<<std::endl;
+ abort();
+ }else{
+ toLeft->toRight=this;
+ }
+ }
+ if(toRight){
+ if(toRight->toLeft){
+ std::cout<<"There's already a world to the right!"<<std::endl;
+ abort();
+ }else{
+ toRight->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;i<lineCount;i+=10){