[Tutor] A Couple of Questions
Fri, 23 Feb 2001 16:31:37 -0800
Here is my situation: Ever since playing Zork way back when, I've really
wanted to write my own text adventure. I've also wanted to learn to code. So
I'm combining the two and learning Python by, amongst other things, writing
up a very simple text adventure.
I'm still in the pre-coding stages of it. There's a couple of problems I've
encountered that I'm hoping some of you can help me with.
The first is classes. I'm thinking of having everything in my game fit
within five classes: Player, Rooms, Objects, Mobs and Game. The first four
of these are self-explanatory. The Game class is sort of a catch-all for
different things, like the UI and maybe networking code and whatnot. Can
anyone think of a better way to break things up?
Secondly, if I want to put the information in a text file, rather than
hard-coded into the program, what would be a good format for it, and how can
I make Python read in each class. For example, if I had a text file with a
list of all the rooms, what would the code look like to have Python read in
each room, and assign that information into an instance of the Room class.
If anyone can point me in the right direction, I'd be grateful!
It is pitch black. You are likely to be eaten by a grue.
Get your FREE download of MSN Explorer at http://explorer.msn.com