Side Scroller

BlitzPlus Forums/BlitzPlus Beginners Area/Side Scroller

Siopses(Posted 2007) [#1]
How would I create a side scroller, Is it just one big image
that you move as an animated character moves? Or is it
something else?


CS_TBL(Posted 2007) [#2]
You mean something like classic Gradius? In theory it could be tiles as well as one big pic.

What you do is scroll through a 2d array. This array contains your tiles.


Siopses(Posted 2007) [#3]
You mean, for example pieces to one big image.


CS_TBL(Posted 2007) [#4]
Yeah, you could for example work with 16x16 tiles (on oldskool computers with low resolutions 8x8 is more conventional), and have all kinda tiles in there.. platforms, backgrounds, rocks, stars, etc. and then you make a map (a 2d array for each layer) based on these tiles.


Siopses(Posted 2007) [#5]
Your talking about mappy, right?


CS_TBL(Posted 2007) [#6]
comparible.., I make my own map-editors.. but it's the same idea.


Siopses(Posted 2007) [#7]
Yeah, I understand why; Mappys crazy hard to use, especially
for me- and if you have complex images, forget it.


El Neil(Posted 2007) [#8]
im making a scroller at the mo and the general approach i use is:

- put an imaginary camera in the bottom left corner of the screen


;during the loop

- work out where in your tile grid the camera is

- using a for/next loop, draw all of the tiles "x" number of spaces to right of the camera and "y" number of spaces above the camera, so they cover the edges of the screen. there is no need to draw any more than that, cos you wont be able to see them. (make sure you offset this drawing by the amount the camera has travelled through its current column. for example, if the camera is halfway through a column of tiles, you nee to draw the tile range, but offset by half a tile's width. this will give you smooth scrolling)

- repeat for as many layers as you have.

- draw all your other stuff.

- scroll your camera slightly by nudging its imaginary coords a couple of pixels to the right. you might want to have a separate camera variable for each layer and scroll the layers nearest the player slightly faster than layers that are further away. this will create a parallax effect. if you do this, dont forget to give the faster layers a bigger grid, or you'll run out of tiles and get a nasty crash. youll also have to do a bit of maths to make sure the layers all finish at the same time.

- start again.



follow these steps and youll have a basic scrolling engine.

neil