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

Re: [pygame] Creating sprites on the fly?



Sure....

Make a default sprite.

Hold a list of sprites in a dictionary-like class...

def __getattr__(key):
   if self.sprites.has_key(key):
     return self.sprites[key]
   else:
     return self.default_sprite

--
Thadeus





On Mon, Apr 12, 2010 at 7:08 PM, Julian Marchant <onpon4@xxxxxxxxx> wrote:
> Hi, I'm somewhat new to Python and very new to Pygame, so please bear with
> me if I sound like an idiot.
>
> Is it possible to create sprites on-the-fly?
>
> In my load image function, I would like to add an option to create a simple
> back-up sprite (a black rectangle will suffice) on-the-fly if the requested
> sprite is unavailable, to allow the game to still run.
>
> --éæ
> Website: http://onpon.co.nr/
>