DaedalusX,
It might help to look at my reply to JHA in the following thread.
http://darkbasicpro.thegamecreators.com/?m=forum_view&t=32618&b=4
Specifically my response with the screenshot & source code button.
---
The basic idea is to use a mutli-dimensional array (3 dimensional in this case).
Dim world_array(Xtiles,Ytiles,numoflayers)
*! Remember arrays start at 0 so for a (20 tile by 20 tile) world with 5 layers you would.
dim world_array(20,20,5)
when indexing into this array you would have
world_array(<0 to 19>, <0 to 19>, <0 to 4>
hence, the top-left tile the world at the lowest layer would be
world_array(0,0,0)
*******
Layer 0: Are used for base terrain and drawn beneath the player.
Layer 1: can be used as a fringing/transition layer or for highgrass, bridges over water, secret passages(if you placed a wall tile on this layer the character would be able to walk over it, I use this for walkable water and the like) etc.. and are drawn beneath the player
Layer 2: This is the layer that your character is on. Any tiles placed in this layer your character will collide with and not be able to walk on. eg. tree stumps/trunks, items like barrels, deepoceans, mountains, other characters.
layer 3: Tiles that appear above the player eg.s (tree limbs, bridges the charcter walks under
layer 4: I use this layer for effects or sometimes I decide to have the character at level three if I need more effects for tiles underneath.
By using this method, you only need to check for collision on one layer (in this example layer 2). So the collision is internally handled in the design of the map. As well as the drawing order. You always draw layer 0 first, then layer 1, layer 2, 3, and finally 4. A value of 0(a good value to choose) in any layers array index is transparent. A small example(only showing layer 0,& 2) of a island surounded by ocean. The island is walkable so will be drawn on layer 0, the ocean is not walkable so it will be dran on layer 2. assume that 0=transparent: 1=ocean : 8=land
layer 0 (walkable):
0000000000
0088888800
0088888800
0088888800
0000000000
layer 2 (not walkalble):
1111111111
1100000011
1100000011
1100000011
1111111111
when drawn to the screen it the world would look like this
1111111111
1188888811
1188888811
1188888811
1111111111