[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Collisions + tiledtmxloader?



On Jan 1, 2010, at 9:49 AM, Alex Nordlund wrote:

> Hello,
> 
> I'm part of team working on a small project using DR0ID's excellent
> tiledtmxloader.
> The tiledtmxloader is completly awesome and is the godsend we prayed
> for, unfortunately due to our (current) incompetence we cannot
> currently utilize this holy grail fully.
> 
> But enough of being a suckup; we're having some slight problems with
> character-world co-ordination, especially the part about collisions.
> 
> Currently we have a way of moving the background (the tiles on a
> surface) around and we got the character on top of that, moved by the
> same logic (although independently).
> 
> Does anyone know how we can make the character tell if it's stepping
> on a tile or not?
> 
> svn co http://tdist.svn.sourceforge.net/svnroot/tdist/ for the code
> 
> tiledtmxloader.py has the loader, rest is in game.py

It's difficult to give you a specific recommendation, given this information (I'm afraid I'm too lazy to check out your code right now). Is the game 2D or 3D? Is it physics-based, and if so does it use a physics engine to handle collisions? If not, how are you handling collisions?

A general way to handle collisions with a character's feet is to use ray casting. If you are using a physics engine, it can probably do the heavy lifting for you. If not, it is fairly straightforward math (Basically intersecting a ray with a bounded plane), though certainly easier for 2D than 3D.

-Casey