I’m working on a puzzle game where the player can walk off the screen and wrap around to the other side. That effect is also see in arcade games like the classic Asteroids where the asteroids and space ship wrap around the screen.
While my first try at writing that code worked, it turned out to be much longer than I needed it to be. What you’re going to see here is very few lines and works really well.
Want The Sample Source Code?
If you’re a member of this site, make sure you’re logged in and you should see a link right below here where you can download the code for this cool function. It comes with a little demo program so you can see it in action.
If you’re not a member, register and then look for an email from me — click the verification link in that email and you should be good to go. (If you don’t see an email from me, look in your spam/junk folder — it sometimes gets misrouted.)
Click here to join (free!) and download the project files (or log in if you’re already a member). After logging in you will see the link below,