Archived

This topic is now archived and is closed to further replies.

Scrolling

This topic is 5777 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am still learning the art of games development and need some help with scrolling. Ultimatly i want to write a game that scrolls horizontally in a "Mario" or "Sonic" style. I''m having massive difficulties with getting my head round how to do this. I figure that to start with, my playing area should be roughly 4 times the size of the screen (3200*600). Now i realise that i''ll have to split this up into much smaller pieces and probably place the pieces into an array. I was thinking squares of say 50*50 pixels. Then i will have to blit the squares to the screen as needed to create the effect of scrolling. I can''t get my head around how to implement this though. I have example programs demonstrating some games programming techniques that i plucked of the internet(Page flipping, collision detection, Initialise Direct Draw, Display Bitmap, Z Ordering, Clipping and more...). All of these programs work, and i have spent many hours looking at the code for them. I thought that as these programs already work, all i will have to do is add the scrolling to one of them. Although i am grasping some of what is going on i feel as though i''m missing the most important bits. Would anyone (and there is no reason why you should) mind taking a look at some of the code i''m working with and then if possible explain how i might be able to implement it? I have put up most of the code from two of the example programs i have (Pixel_Manipulation and Move_Multiple_Bitmaps) at the following address: http://homepages.shu.ac.uk/~rpallas/directx/index.html just incase you were wondering what i already got.

Share this post


Link to post
Share on other sites
Look up 'TileMap's'.



For y=Player.Y to Player.Y+ScreenTilesY
For x=Player.X-1 to Player.Y+ScreenTileX+1
Blit.surface(bitmap[tiles[x][y]], x+Xoffset, y, TileWidth, TileHeight)
Next X
Next Y

blit.backbuffer(surface, 0,0,ScreenTilesX*TileWidth, ScreenTilesY*TileHeight)



Increment Xoffset from 0 to TileWidth as player moves (smooth scroll). Draw extra tiles to allow this both left and right of screen. When you blit to the backbuffer only blit the middle portion of the backbuffer,


,Jay


Edited by - Jason Zelos on February 21, 2002 6:25:35 PM

Edited by - Jason Zelos on February 21, 2002 6:27:03 PM

Share this post


Link to post
Share on other sites
It''s a good idea to use tile dimensions that are powers of two, so that the math can be resolved to shift operations (either by you or the compiler optimizer).

Instead of 50 x 50, can you make it work w/ 32 x 32 or 64 x 64?

There is a good article on Smooth Scrolling by Jim Adams in the articles section on this site.

Share this post


Link to post
Share on other sites