]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
improved world traveling
authorClyne Sullivan <tullivan99@gmail.com>
Thu, 10 Sep 2015 20:04:37 +0000 (16:04 -0400)
committerClyne Sullivan <tullivan99@gmail.com>
Thu, 10 Sep 2015 20:04:37 +0000 (16:04 -0400)
src/main.cpp

index 52ef69beaa22913405e2510f98573a85f1ca0101..3d1afb611a30247e7249393c8ed749956b12fc04 100644 (file)
@@ -95,12 +95,21 @@ int main(int argc,char **argv){
                player.loci.x += player.vel.x;
 
                gw=currentWorld->getWidth();
-               if(player.loci.x+player.width>-1+gw&&currentWorld->toRight){
-                       goWorldRight(currentWorld);
-                       player.loci.x=-1+HLINE;
-               }else if(player.loci.x<-1&&currentWorld->toLeft){
-                       goWorldLeft(currentWorld);
-                       player.loci.x=currentWorld->getWidth()-1-player.width-HLINE;
+               if(player.loci.x+player.width>-1+gw){
+                       if(currentWorld->toRight){
+                               goWorldRight(currentWorld)
+                               player.loci.x=-1+HLINE;
+                       }else{
+                               player.loci.x=gw-1-player.width-HLINE;
+                       }
+               }
+               if(player.loci.x<-1){
+                       if(currentWorld->toLeft){
+                               goWorldLeft(currentWorld);
+                               player.loci.x=currentWorld->getWidth()-1-player.width-HLINE;
+                       }else{
+                               player.loci.x=-1+HLINE;
+                       }
                }
 
                render();