LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

bg collision

Root / Programming Questions / [.]

KomodoCreated:
ok so i figured out how sprite collision works ,but how do you do it with bg tiles instead of sprites for things like opening a chest or walking through a door.

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!

You can use something called SPECIAL_MAP[bg_size_x,bg_size_y], and when you press A check for certain values, when you move check certain values, etc. Basically an array holding all 'special' interactions data.

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!
will that actually work because i was thinking about doing that?

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"

SPHITRC is only sationary, not dynamic.
What do you mean? You can specify the direction of movement for the rectangle, if you wish to do that.

SPHITRC is only sationary, not dynamic.
What do you mean? You can specify the direction of movement for the rectangle, if you wish to do that.
So SPCOLVEC? I have no idea what it does, or how to use it.