aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2015-09-10 16:04:37 -0400
committerClyne Sullivan <tullivan99@gmail.com>2015-09-10 16:04:37 -0400
commit01796ef04688e10cfbc4c3aa63999f7dfabeb64e (patch)
tree39298eba6ffc0a12184d0860bf3285625fb77b7d /src
parent820bd80587b5dbba1f9a174ca17c5461880b97c1 (diff)
improved world traveling
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp21
1 files changed, 15 insertions, 6 deletions
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&&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();