[Tutor] Module Packages

Alan Trautman ATrautman at perryjudds.com
Thu Oct 30 10:34:20 EST 2003


Warning a hunk of theory here read on at your discretion.

Zak,

I too am working on a really similar type thing. I don't know if this will
help but it addresses some of the concerns about handling. I XML'ed it
partially for the experience and partially for the reasons you mention.

I decided there should be a master file of monsters. Each area would have
its own monsters. These would be kept in an XML file with directions to the
image map, name, info, damage etc... To add a general monster append it to
the xml file, to add a monster to a dungeon add it to the local monster
file. I use a folder for each adventure area. 

This way I only need on monster handler for the whole game. It just needs to
be pointed to the correct xml file to get the monster. More importantly it
means the user only has to create a profile to add a monster. Additionally
using xml format means that not every monster has a record for every
possible action: rats don't need have documentation about their magic
ability. The problem is being the programmer you have to provide an action
script with enough flexibility to allow neat new monsters to be created.

This is also the way I document the world and adventure areas.

The huge advantage/disadvantage to this method is of course speed unless you
preload a huge amount into memory. I will never program a thumb speed game
so I this this is an advantage because I can program rich environment vs.
speed.

Ok, wow that's a lot. I'm interested to see what people say.

Alan


>> In the one-file format, I have the following classes
>
> If you mean by one-file format that you have one
> class per file, can I ask why? If the classes are
> related its usually better to keep them together IMHO.

Sorry, I meant the entire program was in one file. It finally became
unmanageable and I wanted to break it up.

> Why separate Monsters from other Entities? And why
> separate Entities at all, why not just two modules, one
> for the Entities and another for the Game itself.

It's to ease the addition of new monsters. I'd like to be able to add
monsters very easily, so I'd like each one to be dealt with in its own
file. I'm planning on having about 52 different monsters (probably more),
so I don't want them all in the same file.

> Presumably you might reuse the Entity module but less
> likely to reuse the game?

Yes. I will reuse the Entity module a ton. It is the basis for monsters,
players, traps, special effects, anything that has a presence in the game.

> Exactly, its easier to use the module to hold all the class
> definitions. Fine grained file structures tend to be used
> in things like C++ and Java as a mechanism for controlling
> compilation times, but they add a lot of undue complexity
> to a project in my experience.

Right, but it's not to control compilation, it's to coding easier. Easier
to find a monster, and easier to add a new one.

> Alan G.

I hope I've made more sense of what I want to do. My eventual goal is to
make adding new features as easy as plopping in a .py file (say, for a
monster or a new level-building algorithm), and make it easier to find a
specific section of code. Going from just that, what would you recommend?

---
Zak Arntson
www.harlekin-maus.com - Games - Lots of 'em

_______________________________________________
Tutor maillist  -  Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor



More information about the Tutor mailing list