Using the 'Onscreen Image' in collisions

BlitzPlus Forums/BlitzPlus Programming/Using the 'Onscreen Image' in collisions

Rico(Posted 2003) [#1]
I was wondering if it is possible to use the images stored in Frontbuffer and Backbuffer in collision detection - without having to do a GetImage command to put the onscreen image into a seperate bitmap first.


Ross C(Posted 2003) [#2]
i don't think that's possible, but please don't do GetImage or GrabImage i think it's called. It is very slow compared to CopyRect me thinks.


Neo Genesis10(Posted 2003) [#3]
Not exactly Rico, but there are workarounds. Try this out.

ship = LoadImage("spaceship.bmp")

collision = CheckCollision( BackBuffer(), ship, playerX, playerY )

Function CheckCollision( buffer, image, x, y, frame=0 )
	img = CreateImage(GraphicsWidth(), GraphicsHeight())
	CopyRect 0, 0, GraphicsWidth(), Graphicsheight(), buffer, 0, 0, ImageBuffer(img)
	val = ImagesCollide( image, x, y, frame, img, 0, 0, 0)
	FreeImage img
	Return val
End Function

Although it uses a seperate image it is a self-contained function so shouldnt intrude too much.


Rico(Posted 2003) [#4]
OK - I'll give it a try. Thanks Neo