Skip to main content
gamedev.net
🔒 Locked

[SDL] Scrolling

Started by NighTiger 3 replies 3.5k views
Original Post
NighTiger
NighTiger
Hi guys, I would like to make a game with a world more big than the dimension of the screen. Something like: screen 320x200 scrolling_screen: 1600x1000 in the scrolling_screen i would like to paste N tiles for make the world. Anyone have source or can give me some info to implement this feature in the better way possible? tnx
Spudder
Spudder
SDL_BlitSurface allows you to specify a source rect on the source image to blit from to only draw part of the image to the screen. So to implement scrolling you would simply need to adjust the X or Y values of the source rect used when blitting the image, quite simple really.
IronGryphon
IronGryphon
The Cone3d tut 6 is a similar situation. Where it is only a scrolling background, it is a good example of how to work with areas larger than the screen. You would only have to modify the code that causes the screen to scroll.
SDBradley
CGP
"A person who won't read has no advantage over one who can't read." ~Mark Twain
Rob Loach
Rob Loach
I put in two extra variables to handle the camera: CameraX and CameraY. Whenever you're drawing something on the screen, offset the object you're drawing by CameraX and CameraY. Then, whenever you're drawing your screen, it will automatically move the objects for you and you'll have a dynamic camera by changing the values of CameraX and CameraY.
Rob Loach [Website] [Projects] [
NighTiger
NighTiger
Tnx guys...
so in those way I only need a layer for the scrolling... mmm so I will have 2 surface, the screen and the background with the first group of tiles... right?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.