January 24, 2021, 01:18:56 PM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Forum
Help
Search
Gallery
Login
Register
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Algorithms
»
[bmx] CollideImage2 by RepeatUntil [ 1+ years ago ]
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: [bmx] CollideImage2 by RepeatUntil [ 1+ years ago ] (Read 666 times)
BlitzBot
Jr. Member
Posts: 1
[bmx] CollideImage2 by RepeatUntil [ 1+ years ago ]
«
on:
June 29, 2017, 12:28:38 AM »
Title :
CollideImage2
Author :
RepeatUntil
Posted :
1+ years ago
Description :
This function just use CollideImage, but returns an array *without* the object we are testing. This allows collision between images of the same layer (which is not possible with CollideImage).
Use it like this:
CollideImage2(x,y,frame,0,playerLayer,player) (collideImage would work as well)
Then, later on, to check collisions:
if collideImage2(x, y, frame, playerLayer, 0, null, self) then blah
(where self is the image you are currently testing)
Code :
Code: BlitzMax
' Function checking the collision, but will remove the testedObject from the list of collision. This allows
' collision for objects of the same layer.
Function
CollideImage2:
Object
[
]
(
image:TImage, x, y, frame, collideMask%, writeMask%, id:
Object
, testedObject:
Object
=
Null
)
Local
collidedObjects:
Object
[
]
= CollideImage
(
image, x, y, frame, collideMask, writeMask, id
)
' Test if the object is present in the collision list
Local
testedObjectPresent:
Byte
=
False
For
Local
collidedObject:
Object
=
EachIn
collidedObjects
If
collidedObject = testedObject
Then
testedObjectPresent =
True
Next
' Create the new array we will return
Local
dim
If
testedObjectPresent
Then
dim = collidedObjects.length -
1
Else
dim = collidedObjects.length
Local
collidedObjectsReturned:
Object
[
dim
]
' Remove the object from the collision list if it's present
Local
i =
0
For
Local
collidedObject:
Object
=
EachIn
collidedObjects
If
collidedObject <> testedObject
Then
collidedObjectsReturned
[
i
]
= collidedObject
i:+
1
EndIf
Next
Return
collidedObjectsReturned
End
Function
Comments :
none...
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Algorithms
»
[bmx] CollideImage2 by RepeatUntil [ 1+ years ago ]
SimplePortal 2.3.6 © 2008-2014, SimplePortal