From: Clyne Sullivan Date: Thu, 10 Sep 2015 20:04:37 +0000 (-0400) Subject: improved world traveling X-Git-Url: https://code.bitgloo.com/?a=commitdiff_plain;h=01796ef04688e10cfbc4c3aa63999f7dfabeb64e;p=clyne%2Fgamedev.git improved world traveling --- diff --git a/src/main.cpp b/src/main.cpp index 52ef69b..3d1afb6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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&¤tWorld->toRight){ - goWorldRight(currentWorld); - player.loci.x=-1+HLINE; - }else if(player.loci.x<-1&¤tWorld->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();