bg collision
Root / Programming Questions / [.]
KomodoCreated:
I don't know this either but it would be very helpful to know. I know an easy way out of this though. Make sprites of the thing then just do what you were going to do with the background with the sprites!
A function that should help is SPHITRC, which checks for a collision between a sprite and a rectangle.
http://smilebasic.com/en/reference/#sprite (you should ctrl+f it)
SPHITRC is only sationary, not dynamic. If you want to check in certain directions of the sprite, use a Sprite Display Coordinate to Background Coordinate conversion sequence.
SPOFS Management Number of Sprite OUT Variable X, Variable Y 'BGCOORD Converts display coordinates to BG screen coordinates, or vice versa 'Format BGCOORD Layer,Source X-coordinate,Source Y-coordinate[,Mode]OUT DX,DY 'Arguments Layer Layer number: 0-3 'Source X-, Y-coordinates Coordinates to convert (BG character coordinates or display coordinates) 'Mode Conversion mode: 0-2 '0: Converts BG screen coordinates to display coordinates '1: Converts display coordinates to BG screen coordinates (in character units) '2: Converts display coordinates to BG screen coordinates (in pixel units) 'DX,DY Variable to store the converted coordinates (BG character coordinates or display coordinates) 'Then use BGGET in the area where the BGCOLISSION will occur... its actually sorta complex to explain this one, so use the pop up help for the arguments. BGGET "code"