Saturday, August 25, 2018

c++ - 2D Circular View/Background Wrapping SDL for Game


In the games such as Defender (1980 arcade) and Defcon, the player can move/scroll in one direction infinitely because the level/terrain simply wraps over and over again(like if it was wrapped around the side of a cylinder).


I am more interested in the wrapping mechanics of Defcon which wrap(on the x-axis) and zoom the entire level. Here is a link to view the game.


To make images(such as a background) wrap is it a per-pixel approach? Is there a function? What methods are there to achieve the circular wrapping of a level?



Answer



When I have used a repeating background image, I used two copies of the image side by side and scrolled the pair. When one gets to the edge of the screen, reposition it off the screen.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...