Right, well I've used GetSpriteInCircle, SpriteRayCaste, and GetSpriteDistance. I've also written my own code for overlapping circle collisions, and distance checks.
In every case the player can spawn too close to the rocks.
I can only guess that the problem must be in how I'm returning information from the detection function. There's only so much you can do with print statements to try and figure out where the problem is, but that's about the only thing I haven't really changed.
ExitFunction is not highlighted in the IDE, but it is listed in the docs, and I'm using it in other parts of my code without apparent problem.
I'm wondering if, because I'm using it inside a loop, it's just bailing out of the loop rather than the function, so I'm getting the wrong value returned.
Just to clarify, the detection code should be called until it returns RFS_TRUE indicating the player is at least the minimum distance away from all rocks.
here's my calling code:
safe = RFS_FALSE
// if we spawn to close to a rock, pick a new position
Repeat
// pick a random position
newX# = Random(GetSpriteWidth(RFS_player.cloneID), GetDeviceWidth()-GetSpriteWidth(RFS_player.cloneID))
newY# = Random(GetSpriteHeight(RFS_player.cloneID), GetDeviceHeight()-GetSpriteHeight(RFS_player.cloneID))
SetSpritePositionByOffset(RFS_player.cloneID, newX#, newY#)
safe = RFS_SpawnCheck(RFS_player.cloneID, GetSpriteHeight(RFS_player.cloneID)*2.0)
Until safe = RFS_TRUE
And here's my detection code:
Function RFS_spawnCheck(spriteID, distance#)
For i=0 to 26
if GetSpriteExists(RFS_rocks[i].cloneID) = 1
If GetSpriteDistance(spriteID, RFS_rocks[i].cloneID) < distance# Then ExitFunction RFS_False
EndIf
Next i
EndFunction RFS_TRUE