Re: RPG game in UML



weer1 wrote:

> I am developing an RPG game and was wondering if I would have
> advantages when I use some OO for the battle-engine. Actually I am now
> trying to model the whole game in UML, just for the fun of it.
>
> I have a model like this now:
>
> GameObject
> ^ ^ ^
> | | |
> Hero Tree Stone

The source to the original Rogue (the character-mode game on a VT100 console
where you crawl a dungeon, fighting each letter of the alphabet until you
get to the Amulet of Yendor) used that pattern, in C. Specifically, it had a
'struct Object' with a bunch of members. Suppose one was Power. To
"polymorph" this into a Monster, C used

#define Object Monster
#define Power Strength

That's not really polymorphism (and I'l get beat up if I don't get to be the
first to remind you that the C languages should not abuse the
preprocessor...).

The polymorphism comes when each object has a pointer to a behavior
function:

struct Object {
int Power;
void (*behave)(Object * obj);
...
};

Now the main work loop of the program only needs to traverse a list of
objects, calling each one's behave() function. This will polymorphically
adjust its monster or object, adjust the map, and/or adjust other objects.

> Thats about it. I also got a simple relation between hero---player.
> And an Action-class still hanging loose.
>
> Now the fun starts.
>
> Lets presume there are only hero-type characters in this game so every
> player(user) has a hero (not A character). I think weapons play an
> important role. A Tree could be the weapon for a hero. Even a tree
> could BE a hero (yes, you can play a tree in this game!).
>
> If I do, how do I model these things?

Modern games animate everything. Getting attacked by a huge B might once
have been scary (if you were _really_ low on ammo, weapons, and hit
points;), but nowadays that bat must flap and stuff.

So, each aspect of each game object is, in turn, an object. A Bat is an
object containing a Wing object pointing to a State of Flapping, containing
an index into a Flap Animation. Attacking a bat requires sending a message
to the root object, so its AI component decides to flit away, so it repoints
its State to FlapAway, and synchronizes the index of the animation to the
matching index, permitting a smooth transition.

This all requires a generic component hierarchy (Composite Pattern), a
system to render that hierarchy to the screen (Interpreter Pattern), and a
phat message bus to carry all these messages around (Observer Pattern
between any two components). Without all those objects, you either use
threads (which are hardly a design solution), or your attack() method does
not return until the Bat has animated its wing in FlapAway mode.

>From here, you may want to download one of scores of open source games and
read their source. Game programming is one of the hardest disciplines
available today.

--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!


.



Relevant Pages

  • Re: Furniture City Shootout 2005
    ... La Cosa Nostra finished double game point behind them. ... > out against a small HOSS pretty close. ... It's 5-3 BAT ... LCN jumps on Triangulose 4-0 before Triangulose trades to 9-5. ...
    (rec.sport.disc)
  • Re: THE BIG STERN INDY REVIEW ENJOY
    ... Plastics stern finally did a good job with plastics on this game. ... The main theme will make you never want to hear the indy theme from ... One of the scenes is from when indy is a young boy and it takes you ... Extra Ball animation, mystery animations, replay animation all in ...
    (rec.games.pinball)
  • Re: THE BIG STERN INDY REVIEW ENJOY
    ... Plastics stern finally did a good job with plastics on this game. ... The main theme will make you never want to hear the indy theme from ... One of the scenes is from when indy is a young boy and it takes you ... Extra Ball animation, mystery animations, replay animation all in ...
    (rec.games.pinball)
  • CFP: GAMEON 2007, November 2-22, 2007, University of Bologna, Bologna, Italy
    ... The aim of the 8th annual European Game-On Conference on simulation and AI in Computer Games, ... Game Development Methodology ... Game Development Methodology, Game Design and Research Methods, Production Roles, Techniques ... level of detail-oriented rendering; Methods for scaling animation quality; Scaling ...
    (comp.graphics.animation)
  • cfp: GAMEON 2007, November 20-22, 2007, University of Bologna, Bologna, Italy
    ... The aim of the 8th annual European Game-On Conference on simulation and AI in Computer Games, ... Game Development Methodology ... Game Development Methodology, Game Design and Research Methods, Production Roles, Techniques ... level of detail-oriented rendering; Methods for scaling animation quality; Scaling ...
    (comp.graphics.visualization)