Slopes in a Tile-based platformer

Started by
2 comments, last by signal_ 15 years, 8 months ago
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.
Advertisement
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.
OK, will do. Thanks for your help.
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

This topic is closed to new replies.

Advertisement