Conversion List

BlitzMax Forums/BlitzMax Programming/Conversion List

Nigel Brown(Posted 2005) [#1]
Is there a list of equivalent functions in BMX that we used in B3D? example DrawBlock() used extensively throughout my B3D programs, now I am unable to find the function under BMX!


Perturbatio(Posted 2005) [#2]
DrawBlock:
Function DrawBlock(Image:TImage, x#, y#, frame:Int=0)
	Local oldBlend = GetBlend()
	SetBlend(SOLIDBLEND)
	DrawImage(Image, X, Y, frame)
	SetBlend oldBlend
End Function


MouseXSpeed, MouseYSpeed and MouseZSpeed:

Function MouseXSpeed:Int()
	Global lastX:Int =0
	Local result:Int = MouseX()-lastX
	lastX = MouseX()	
	Return result
End Function


Function MouseYSpeed:Int()
	Global lastY:Int =0
	Local result:Int = MouseY()-lastY
	lastY = MouseY()	
	Return result
End Function


Function MouseZSpeed:Int()
	Global lastZ:Int =0
	Local result:Int = MouseZ()-lastZ
	lastZ = MouseZ()	
	Return result
End Function




semar(Posted 2005) [#3]
@Perturbatio,
am I right to assume that the 'Global LastX' declaration in the function is like a VB static variable ? That is, a variable which is set to 0 only the very first time that function is called, and then it preserves the last value ?

Using the Perturbatio code, you can even make your own class (that is, type) with BMax, or a module if you like, and put in all the B3D functions you need:
Type B3D
Function DrawBlock(Image:TImage, x#, y#, frame:Int=0)
	Local oldBlend = GetBlend()
	SetBlend(SOLIDBLEND)
	DrawImage(Image, X, Y, frame)
	SetBlend oldBlend
End Function
 

'MouseXSpeed, MouseYSpeed and MouseZSpeed:
Function MouseXSpeed:Int()
	Global lastX:Int =0
	Local result:Int = MouseX()-lastX
	lastX = MouseX()	
	Return result
End Function


Function MouseYSpeed:Int()
	Global lastY:Int =0
	Local result:Int = MouseY()-lastY
	lastY = MouseY()	
	Return result
End Function


Function MouseZSpeed:Int()
	Global lastZ:Int =0
	Local result:Int = MouseZ()-lastZ
	lastZ = MouseZ()	
	Return result
End Function

end type
Then you can call each function using just one statement (because they are functions, then you do not need to create an instance of the type):
B3D.Drawblock(myimage,x,y)


Sergio.


Curtastic(Posted 2005) [#4]
now imagerectcollide?


Perturbatio(Posted 2005) [#5]

@Perturbatio,
am I right to assume that the 'Global LastX' declaration in the function is like a VB static variable ? That is, a variable which is set to 0 only the very first time that function is called, and then it preserves the last value ?



Yes.

now imagerectcollide?

That's a little trickier since you need to take into account Scale and Rotation (which B3D doesn't).