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

[pygame] A question about callback functions



I am relatively new to Python/Pygame and I love it so far! Coming from a
C/C++ background, Python is  breath of fresh air :)

I am creating a simple tile-based arcade game using Pygame. As part of the
project I want to have enemy sprites on the board who run their AI
routines from separate scripts. I want this to be modular so users can
drop their own AI scripts into a folder, modify the appropriate ini file,
and then run the game which loads the AI scripts automatically and assigns
them to the proper enemy.

Using C, I would have probably implemented a system using function
pointers to create callbacks but Python doesn't seem to have such
functionality. What techniques would anyone else suggest to implement such
a feature in 'pure' Python?