Scroling Map

Blitz3D Forums/Blitz3D Beginners Area/Scroling Map

Tokra(Posted 2004) [#1]
Can any one sugest a way I can do a scrolling map, to over lay it with the paralax back grou nd for a game I am in the fisrt stages of planning, I have the write a test version to check a few things like randomlay genarating astroids and some of the collition code, but I want to add a scrolling map to it... And need a way to build the scollling map and also the code needed to put em in the the blitz basic prog, if ne one can help..

TA


CS_TBL(Posted 2004) [#2]
<<step 1>>

Make sure you have mapdata.. either stored in a 2d array or bank. In the simplest case you use 1 byte per tile, meaning 256 possibilities.

<<step 2>>

Make sure you've the tile-gfx right. Each byte of the mapdata refers to a unique (part of an) image.

You can go 2 ways:

1: each element in the mapdata refers to an x/y offset in a big image containing all tiles.
2: each element in the mapdata refers to an imagehandle. However, an imagehandle is 4 bytes in size (1 int), so your mapdata becomes rather huge. Advantage is that there's basicly no creative limit about the number of tiles you use, and their size.

I'd say, avoid 2 .. just regard it as some training for a rainy sunday-afternoon :)

<<step 3>>

Make a loop. Within that you loop you have the following parts:

1: some routine that checks for keypresses/mousemoves etc. This routine gives you new coordinates in your map

2: a mapdraw routine, this redraws your whole map, based on the current map-coordinates.



Basicly you have 1 layer now... ofcourse, a 2nd layer should have it's own x/y map coordinates .. if it's some horizon far away that's on the backlayer, you could do something like horizonX=frontX/2 horizonY=frontY/2 .. to name something..


This is a very brief sketch, I'm for now not going into details as it's bedtime here :) Browse the forum.. I did a small map-example for someone once.. (complete sourcecode in my post) it doesn't scroll smooth, and has no multilayers, but it shows how to work with maps/gfx . It's months and months ago .. if I've time tomorrow I'll dig it up.