Hi GC-Martjin,
Here is a small example of how you could make your own Z-Ordering functions. I'm not sure it's the best way, but it should work.
Fredborg
Here is a small example of how you could make your own Z-Ordering functions. I'm not sure it's the best way, but it should work.
; The ImageZ Type Type ImageZ Field image Field x,y,z Field show End Type ; ; Example Usage: ; ; a = LoadImageZ("something.bmp",0) ; b = LoadImageZ("somethingelse.bmp",1) ; Image b is always drawn on top of Image a ; ; Repeat ; Cls ; DrawImageZ(b,rand(0,20),rand(0,20)) ; DrawImageZ(a,rand(0,20),rand(0,20)) ; RenderImageZ() ; Flip ; Until Keyhit(1) ; ; ; LoadImageZ() ; ; Works the same as LoadImage, except you can specify a Z-Order Function LoadImageZ(file$,z=0) image = LoadImage(file$) If image imgz.ImageZ = New ImageZ imgz\image = image imgz\z = z imgz\show = False SortImageZ() Return Handle(imgz) End If End Function ; ; DrawImageZ() ; ; Same as DrawImage, except it doesn't actually draw anything Function DrawImageZ(id,x,y) imgz.Imagez = Object.ImageZ(id) If imgz <> Null imgz\x = x imgz\y = y imgz\show = True End If End Function ; ; SetZOrder() ; ; Lets you adjust the Z-Order of an ImageZ Function SetZOrder(id,z) imgz.ImageZ = Object.ImageZ(id) If imgz <> Null imgz\z = z SortImageZ() End If End Function ; ; SortImageZ() ; ; When a new image is loaded or the z-order is changed, it ; is nescesarry to sort the imagezso the ones with the lowest ; Z-Order are drawn behind everything else. Function SortImageZ() b.ImageZ = First ImageZ flag = True While flag flag = False bb.ImageZ = Last ImageZ While bb<>b bbb.ImageZ = Before bb If bbb = Null Exit If bb\z<bbb\z Insert bbb After bb flag = True Else bb = bbb EndIf Wend b = After bb Wend End Function ; ; RenderImageZ() ; ; Use this immediately before Flip Function RenderImageZ() For imgz.ImageZ = Each ImageZ If imgz\show = True DrawImage imgz\image,imgz\x,imgz\y End If imgz\show = False Next End Function
Fredborg