Log In  


How can I make my character collide with map tiles?

Thx in advance :)

1


I'm kind of new but I think I know this.
If you notice the little colored boxes under your sprite tiles that you can turn on or off.
Those are tile flags.
So you can use one of them to signify which tiles will be considered solid for your player and check it for each solid tile.

Then you can use something like "tile = mget(x,y)" to get what sprite tile is at (x,y) on the map.

Define which flag is solid. There are 8 flags, 0-7.
So we'll just use flag 3 as an example.

Go back and check flag 3 on each of your solid sprites.
Then just do something like "flag_solid = 3" and then use "fget(tile,solid_flag)" to check if a tile is solid.

There's probably better ways of doing this, I'm just trying to explain!


If it's not to much trouble, can you please provide me with a cartridge example. It will help me to wrap my head around it.
Thank you for answering.


1

Cart #11278 | 2015-06-14 | Code ▽ | Embed ▽ | No License
1

Here ya go.

It's not perfect by a long shot.
But it displays the core concepts.

The biggest thing is taking note that if you select the grey block in the sprite editor, underneath it is a red bubble turned on. That's the flag i use to check if something is solid.


Supper thank you so much.
Now have to play with it :)



[Please log in to post a comment]