Sign in to follow this  
Badgerigar

Slopes in a Tile-based platformer

Recommended Posts

Badgerigar    122
OK, let's my guy is running on a flat surface and bumping into walls, that all works because collision is based on tiles. But now let's say I introduce tiles with 30/45/60 degree slopes on them. They take up less than a full tile so tile-based collision won't work. As for pixel-perfect collision, I've never seen an example of this kinda thing in python (which I'm coding in) so I have no idea how to use that. If anyone knows of anything like this, or can give me advice in general of how to use sloped tiles, it would be much appreciated. Thanks.

Share this post


Link to post
Share on other sites
Kest    547
If your map is side-view, you can use the x pixel of the character's position to determine the height. IE..

height = tile_height + (character_x - tile_x) * slope_factor

A 45 degree slope would have a factor of 1.

Share this post


Link to post
Share on other sites
signal_    366
Just wanted to drop a quick note regarding the pixel perfect collision in python. Here is a link that you may be interested in:

Pygame PixelPerfect Collision Detection Example

I apologize if this is something you were already aware of, but perhaps you will find it useful. I have not thoroughly studied the code myself, so please respond if you find it useful.

Best of luck

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this