The stupid question is the question not asked | |
PerlMonks |
Re: Adventure Game ->objectby bigj (Monk) |
on May 14, 2003 at 06:49 UTC ( [id://257982]=note: print w/replies, xml ) | Need Help?? |
In object oriented design, you first want to find out what are the given (natural) objects and the "doings" that have to be done. I normally start with a simple description of the used objects and actions done that shall be implemented to the application.
First of all, you have rooms in your advanture game. Every room has a name and there are several items in there. Then there is a map. The map can be loaded and initializes all room objects. It also can tell (in the initialization) to the rooms what are their neighbours. Then there is of course a player. The player has an inventory of items, he/she knows where he/she is (his/her current room), he/she has a point score. He/She can do one of the following actions: move(to north/south/west/east), take an item, look to an item (both perhaps only described by its name). The whole is united as game, consisting of map, one or several players and the possibility to initialize a game, to start and end it. After this description it should be easy to find out an object oriented design. Thus we have the following objects and methods (might be not full complete, but it's you who have the overview of your game, not me :-)) Having all these objects, now it is easy to write someting like a main server. In pseudo code it's quite that simple: While a client (one player) would now only do the graphics (pseudocode): Of course, that's quite only my idea of an object oriented design. But to answer your main question, in my opinion, it's important to seperate the parts that are valid in all adventure games (rules, basic actions, a map) from them that are only valid in your (your current map, nr of players, ...) specific adventure games.
Greetings,
In Section
Seekers of Perl Wisdom
|
|