Using the 'Onscreen Image' in collisions

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

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.

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.

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.

OK - I'll give it a try. Thanks Neo