ImagesCollide problem

BlitzPlus Forums/BlitzPlus Programming/ImagesCollide problem

MattVonFat(Posted 2004) [#1]
I'm using images collide but it sparks off at random points!

Its a 640x480 graphics size and this is the code to create a new enemy:

a% = Rand(1,120)
	If a = 5
		o.obsticle = New obsticle
		o\hnd = LoadImage("germanp.png")
		MaskImage o\hnd, 255, 0, 255
		o\kill = 1
		o\x = Rand(95,495)
		o\y = -25
	End If

Later on i use this very short thing to see if the images are overlapping:

For o.obsticle = Each obsticle
		If ImagesCollide(o\hnd, o\x, o\y, 0, player, px, py, 0)
			Print "SO"	
		End If

Both of these are contained in separate functions. The player co-ords involve the x changing as the player moves but the y staying the same and the enemy has the x staying the same and the y changing. The problem is, sometimes without even having the enemy on the screen it says the images have collided and sometimes it only happens when i get about 100 pixels away. But it always goes off withut the two images colliding. Its been a while since ive used Graphics mode but i don't think i have done anything wrong.

RectsOverlap and ImagesOOverlap also dont work.

Thanks for any help


WolRon(Posted 2004) [#2]
Make sure that all of the variables involved (player, px, py) are either Global or passed to the function.

Your code posted looks OK. What's the point of printing "SO"?

Try Debug mode and putting a Stop in your ImagesCollide If routine. Then check the variable values at the moment the collision occurs. This may let you on to what is happening.

MattVonFat(Posted 2004) [#3]
Ok i'll try that. The reason for the SO is because i had put an End in there and it was getting annoying having to kep restarting so i thought a Print would be better. And i didn't know what to put.