Can somebody please write me a sample code showing how check a collision between 2 objects of the SAME type? Because this doesn't work...
If imagescollide(im,a\x,a\y,0,im,a\x,a\y,0)
If imagescollide(im,a\x,a\y,0,im,a\x,a\y,0)
For Apple.AppleObject=each AppleObject For OtherApple.AppleObject=each AppleObject If Handle(Apple)<>Handle(OtherApple) then If ImagesCollide(Apple\Image,Apple\X,Apple\Y,Apple\Frame,OtherApple\Image,OtherApple\X,OtherApple\Y,OtherApple\Frame) then ;do whatever you want now that you've detected a collision endif endif next next
Type AppleObject Field Ripeness Field Taste Field Color Field Name$ end type Apple.AppleObject=new AppleObject Apple\NAme="jonathan" AppleHandle=Handle(Apple) ;The Handle(Apple) command returns an integer which holds a kind of pointer to this particular type instance. SecondApple.AppleObject=new AppleObject SecondApple\Name="granny smith" TheFirstApple.AppleObject=Object.AppleObject(AppleHandle) ;the Object command when used as above will return either the relevant type instance as it does here, or null if it does not exist. Print TheFirstApple\Name;should print "jonathan"
A.Appleobject=new AppleObject YetAnotherInstance.AppleObject=new AppleObject CDEF.AppleObject=new AppleObject
For Apple.AppleObject=each AppleObject For OtherApple.AppleObject=each AppleObject If Apple <> OtherApple then If ImagesCollide(Apple\Image,Apple\X,Apple\Y,Apple\Frame,OtherApple\Image,OtherApple\X,OtherApple\Y,OtherApple\Frame) then ;do whatever you want now that you've detected a collision endif endif next next
Type TestType Field x, y End Type a.TestType = New TestType b.TestType = New TestType a\x = 10 b\x = 10 a\y = 10 b\y = 10 If a = b Then Print "The same!" Else Print "Not the same!" EndIf