z-index images ???

Blitz3D Forums/Blitz3D Beginners Area/z-index images ???

dynaman(Posted 2003) [#1]
The z index determines what gets drawn "first" so I think you have it right. I cannot remember if a lower number is drawn first or last though.


jhocking(Posted 2003) [#2]
I am not aware of any z-index. Between your question and dynaman's response I'm also a little confused here; are you asking if it exists or what the numbers mean? If the latter I'll have to try adding a number to LoadImage and see what happens; as I said I wasn't even aware of this.

EDIT: I just tried it and got an error. Unless I missed an upgrade I have no idea what dynaman is talking about. There is no such thing as a z-index, but him explaining how it works would naturally assume that such a thing exists.


fredborg(Posted 2003) [#3]
There is no Z-Order in Blitz. Things are drawn in the order you decide. So if you want ImageA on top of ImageB you need to draw ImageB first and then draw ImageA.

If you want to you can make your own Z-Ordering functions, it's fairly simple. Ask if you need help!

Fredborg


dynaman(Posted 2003) [#4]
I was thinking of the z order in blitz3D. If 2d is what were talking about then blitz does not have any such item.


GC-Martijn(Posted 2003) [#5]
jhocking:
What I did with the LoadImage+number was an example of what I want to have. And yes I'm asking if it exists

Fredborg
If you could make a Z-Ordering fucntion then maybe I can use it , I realy don't know how that is possible and what you make then.

--Maybe in the future they make a z-order in blitz ?
--the draw objects must have an ID right? but that is not visible for us I think

Thanks you Very Much,
GC-Martijn


fredborg(Posted 2003) [#6]
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.
; 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


GC-Martijn(Posted 2003) [#7]
a small example... its big :)

Well It looks cool I'm going to edit/check now.
-
-
Thank You Much,
GC-Martijn