Source language: Translate to:

2D Scrolling Scenery, with depth effect

Share sample pubs, scripts, etc. with other NeoBook users

Moderator: Neosoft Support

2D Scrolling Scenery, with depth effect

Postby Jim Brammer » Thu Feb 07, 2002 6:59 pm

I don't know whether this is really practical, or even usable - just wanted to see if it could be done.    The cartoonish background mountain scenery scrolls slowly from right to left while the foreground scenery scrolls slightly faster to produce the effect of depth (like in Mario Brothers for example).

It uses two images. The moutains background - and the trees & hills foreground. Each image object is copied and set off-screen, to the right.

on-screen / off-screen
Mountains1 / Mountains2
Hills&Trees1 / Hills&Trees2

Both background and foreground pictures are seamless images. When Mountains1 moves left, Mountains2 follows until Mountains1 has gone completely off-screen on the left. Once off-screen Mountains1 moves, to the backside of Mountains2 and begins following Mountains2. The pictures do a sort of a "leap-frog" thing here that creates an endless scroll.

The same thing is happening to Hills&Trees1 and Hills&Trees2, in the foreground but at a slightly faster pace which creates an illusion of depth in the scene.

The problem with it is, even with a Timer - it's a hog. There may be ways to make the code lighter and tighter. Have at it! If nothing else, it's an example of what not to do...

Scrolling Scenery

NeoDezign @
Jim Brammer

Return to Sample NeoBook Pubs

Who is online

Users browsing this forum: No registered users and 1 guest