Hello,
I'm trying the raycast functions but I can't make them work
1) Issue with x and y.
This is the raycast example slightly modified:
+ Code Snippetsetvirtualresolution(480,320)
LoadImage ( 1, "silver.png" )
// a dynamic sprite
CreateSprite ( 1, 1 )
SetSpritePosition ( 1, 240, 160 )
SetSpriteShape ( 1, 2 )
// static sprite on the left
CreateSprite ( 2, 1 )
SetSpritePosition ( 2, 0, 160 )
// static sprite on the right
CreateSprite ( 3, 1 )
SetSpritePosition ( 3, 400, 160 )
do
if ( SpriteRayCast ( 100, 160, 380, 160 ) = 1 )
print ("COLLISION DETECTED")
print(getraycastx())
print(getraycasty())
else
PRINT("NO")
endif
sync()
loop
I've got:
getraycastx =1040
getraycasty = 800
What does it mean?
2.- Issue with collision detection
I made the following test:
+ Code SnippetLoadImage ( 1, "red.png" )
spr =1
for i=0 to 10
for j=0 to 10
createsprite(spr,1)
setspriteposition(spr,i*32,j*32)
setspriteshape(spr,2)
spr = spr +1
next j
next i
y =240
do
if ( SpriteRayCast ( 0, y, 480, y ) = 1 )
print ("COLLISION DETECTED")
print(getraycastx())
print(getraycasty())
print(getraycastfraction())
print(getraycastspriteid())
else
PRINT("NO")
endif
sync()
loop
If I use y=240 I get no collision but if I change it to 241 I get collision...
I don't understand why is giving different results.
Please your help... I'm lost

Thank you