Log In  

How can I make my character collide with map tiles?

Thx in advance :)

P#11139 2015-06-06 01:36 ( Edited 2015-06-15 23:12)

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!

P#11164 2015-06-07 04:06 ( Edited 2015-06-07 08:07)

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.

P#11274 2015-06-13 16:42 ( Edited 2015-06-13 20:42)

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

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.

P#11277 2015-06-14 05:40 ( Edited 2015-06-14 09:44)

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

P#11294 2015-06-15 19:12 ( Edited 2015-06-15 23:12)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2023-02-01 17:00:45 | 0.006s | Q:14