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

Re: [pygame] Moving a sprite along a map.



I done something identical to your needs couple of weeks ago, based on the example from Will (posted already). The basic idea I used was: Implement a logical representation of the map (I used a Grid class, kinda-of bidimensional list) that has a method for returning a list of locations from one point to another. Then, in your character class, when he is not moving I make a random position in the GRid, ask a path to it, and then make it move there. When it reaches the position, it goes all again.

Add to this a little pause each time it reachs it poistion, and you got yourself a pretty realistic movement for npc's.

On 7/25/07, aspersieman <aspersieman@xxxxxxxxx> wrote:
On Wed, 25 Jul 2007 14:44:59 +0200, Luke Paireepinart
<rabidpoobear@xxxxxxxxx> wrote:

> aspersieman wrote:
>> On Wed, 25 Jul 2007 10:33:10 +0200, aspersieman <aspersieman@xxxxxxxxx >
>> wrote:
>>> On Wed, 25 Jul 2007 10:21:24 +0200, Julián Lamas Rodríguez
>>> <julian.lamas@xxxxxxxxx> wrote:
>>>> Well I'm new to Pygame too, but I think I know what you need.
>>>>
>>>> A* is one of the preferred algorithms for pathfinding. Hope this
>>>> could help.
>>> Thanks I think thats exactly what I was looking for :)
>>> Nicolaas
>> Hi again
>> Just in case anybody else was looking for stuff on pathfinding, I've
>> found this cool example. Its written in python.
> Which cool example?
>> Regards
>> Nicolaas
> -Luke

Err...sorry :) One of those days I guess.

Here it is :

http://www.willmcgugan.com/2007/04/20/swim-fugu-swim/

Nicolaas

--

  ~)
   (_---;        The Llama compels me...
    /|~|\
   / / / |