Z-Odering problem

BlitzPlus Forums/BlitzPlus Programming/Z-Odering problem

QuickSilva(Posted 2003) [#1]
Can someone please help me with this? I am trying to implement z-ordering into my map editor to determine
where a tile should be in a map, either in the background or the foreground. I use the left mouse button to
place each tile and it`s z-depth is set depending on the current layer I am working on in the editor, either
0 or 1 (background-foreground.) When it comes to the draw rountine I simple want the tiles with a z-depth of
0 (background) to be drawn first and then the tiles with a z-depth of 1 (foreground) to be drawn on the top of
the background 0 tiles. When using the following function I can draw the background ok then the foreground ok
but when I go back to drawing more background tiles, which should appear behind any placed foreground ones they
appear on top. This is not what I want but I cannot seem to find the problem :( Any help would be great.
Here`s the function.

Phew... Thanks,
Jason.

Function DrawTiles()
For Tile.Tiles=Each Tiles
Select Tile\ZOrder
Case 0
If MapLayerZeroEnabled=True
DrawBlock TileSet,Tile\XPosition,Tile\YPosition,Tile\Number
EndIf
Case 1
If MapLayerOneEnabled=True
DrawBlock TileSet,Tile\XPosition,Tile\YPosition,Tile\Number
EndIf
End Select
Next
End Function


Rottbott(Posted 2003) [#2]
Are you resetting "MapLayerOneEnable" to False after you've finished drawing?


Mr Brine(Posted 2003) [#3]
Hi Jason

could be your using drawblock? try changing it to drawimage
and set any masks using maskimage image,r,g,b.

Hope this helps!

Mr Brine


WoeIsMe(Posted 2003) [#4]
Or, use two seperate sections in the loop (that's how I'd do it)

;;;the loop;;;
while not keydown(1)

gosub backgound_tiles
gosub foreground_tiles

wend

;;;the gosubs;;;

.background_tiles
For alltile.tile=each tile

if alltile\zorder=0 then
     drawimage tile,alltile\x,alltile\y,alltile\number
endif

next
return

.foreground_tiles
For alltile.tile=each tile

if alltile\zorder=1 then
     drawimage tile,alltile\x,alltile\y,alltile\number
endif

next
return



Hopefully this should work!


QuickSilva(Posted 2003) [#5]
Thanks guys, WoeIsMe`s solution worked in the end, cheers :)

Jason.