Collision system bug??

BlitzMax Forums/BlitzMax Programming/Collision system bug??

GfK(Posted 2008) [#1]
Seems that when writing collision layers, the screen origin (as set with SetOrigin) is not taken into consideration as I thought it would/should be.

Run the code below. The collision is set up at the same coordinates as the white square, but is actually detected at the coordinates of the grey square.
Graphics 800,600

SetOrigin 100,100

CollideRect 100,100,50,50,0,1

While Not KeyDown(key_escape)
	Cls
		SetColor 50,50,50
		DrawRect 0,0,50,50'draw a grey square where the collision is being detected (wrong!)
		If CollideRect(MouseX(),MouseY(),2,2,1,0)
			SetColor 255,0,0
		Else
			SetColor 255,255,255
		EndIf
		DrawRect 100,100,50,50'collision should be detected here
	Flip
Wend

Is this expected behaviour? It seems wrong to me.

[edit] Maybe this can be ignored - it seems that Mousex() and Mousey() are oblivious to the origin position if its anywhere other than 0,0... I think that's whats causing the problem...


Jesse(Posted 2008) [#2]
Yeap, looks like a bug to me too. I was looking at the max 2d source and it doesn't use gc.origin_x or gc.origin_y as the draw commands do, of which both are set by SetOrigin. I was looking at the other collition command and they seems to be lacking also.


Jesse(Posted 2008) [#3]
I don't think it should be ignored. I believe that if gc.origin_x and gc_origin_y is added it should work correctly. and won't be a need to do a work around.