Collision detection problem

Recommended Posts

Ok, I am making a game and i need a function to tell if a picture in a gui is touching the color black (0xffffff). To be more descriptive i am outlining all borders of objects that cannot be walked through with black so that the picture cannot move through them. So black basically means wall.

[center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

Share on other sites

I don't know if that's possible... I may be wrong, but what about setting limits on there X/Y coords?

FootbaG
Share on other sites

ok,got it!

```include<"guiconstants.au3">
global \$picx = 195, \$picy = 190
guicreate( "Test" , 400 ,400 )
guictrlcreatepic( "pic.bmp", \$picx , \$picy, 10, 20 )
guictrlcreatepic( "black.bmp", 100, 10, 10, 380 )
while 1
;insert functions to move pic.bmp here.
\$collision = _CollisionDetect( \$picx - 1, \$picy - 1, \$picx +  11, \$picy + 21, "0xffffff" )
wend

Func _CollisionDetect
\$pixel = PixelSearch( \$picx - 1, \$picy - 1, \$picx +  11, \$picy + 21, "0xffffff" )
if @error then Return 0
ElseIf \$pixel[0] = \$picx - 1 then return 1
ElseIf \$pixel[1] = \$picy - 1 then return 2
ElseIf \$pixel[1] = \$picy + 21 then return 3
ElseIf \$pixel[0] = \$picx + 11 then return 4
Endif
EndFunc;==>_CollisionDetect```

Havn't tested it cause im at school but should work...

Edited by fear1313

[center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

Create an account

Register a new account

• Recently Browsing   0 members

×
×
• Create New...