Beginners question about collison detection
BlitzMax Forums/BlitzMax Beginners Area/Beginners question about collison detection| 
 | ||
| How can I get it to register if I have two images that have no colors masked at all? I can provide code if necessary | 
| 
 | ||
| Heres the quickest example I could come up with... Blue ball... (Right click and save image as)  Yellow Ball (Right click and save image as)  
Strict
Local ball1:TImage = LoadImage("Ball_Yellow.png")
Local ball2:TImage = LoadImage("Ball_Blue.png")
Local ball1X:Int = 50
Local ball1Y:Int = 50
Local ball2X:Int = 200-32
Local ball2Y:Int = 200-32
Graphics 400,400,0
While Not KeyHit(KEY_ESCAPE)
	Cls 'clear screen before drawing
	
	'check user input
	If(KeyDown(KEY_UP)) If(ImagesCollide(ball1,ball1X,ball1Y-1,0,ball2,ball2X,ball2Y,0) = False) ball1Y = ball1Y - 1
	If(KeyDown(KEY_DOWN)) If(ImagesCollide(ball1,ball1X,ball1Y+1,0,ball2,ball2X,ball2Y,0) = False) ball1Y = ball1Y + 1
	If(KeyDown(KEY_LEFT)) If(ImagesCollide(ball1,ball1X-1,ball1Y,0,ball2,ball2X,ball2Y,0) = False) ball1X = ball1X - 1
	If(KeyDown(KEY_RIGHT)) If(ImagesCollide(ball1,ball1X+1,ball1Y,0,ball2,ball2X,ball2Y,0) = False) ball1X = ball1X + 1
	
	
	'draw balls
	DrawImage(ball1,ball1X,ball1Y)
	DrawImage(ball2,ball2X,ball2Y)
	
	
	'Draw info
	DrawText("X: "+ball1X+", Y: "+ball1Y,10,10)
	
	
	
	Flip(30)
	
	If AppTerminate() Then End 
Wend
Last edited 2011 Last edited 2011 Last edited 2011 | 
| 
 | ||
| I found the problem. I was using If ImagesCollide ball1:TImage,ball1x... etc apparently that doesnt work well with BMax :D Thank you for helping me. |