My small RPG in UML

W

weer1

Hi,


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 Race Class
^ ^ ^
| | |
Hero-----------| |
|---------------------|

Thats about it. I also got a simple relation between hero-player and an
Action-class still hanging loose for spells/abilities later on.

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!). The
GameObject has got x-pos and y-pos
for the field-position.

How do I model these things? Am I on the right track? (and in the right
group) :)

Regards Weerius
 
Z

zero

(e-mail address removed) wrote in @g43g2000cwa.googlegroups.com:
Hi,


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 Race Class
^ ^ ^
| | |
Hero-----------| |
|---------------------|


Am I reading correctly that Hero is a subclass of GameObject, Race, *and*
Class? Remember that inheritance models the "is a" relationship. Seems
to make more sense to me that a Hero "has a" (composition) Race and
Class. Besides, multiple inheritance is very error-prone, best to stay
away unless you know what you're doing.

Thats about it. I also got a simple relation between hero-player and an
Action-class still hanging loose for spells/abilities later on.

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!). The
GameObject has got x-pos and y-pos
for the field-position.

How do I model these things? Am I on the right track? (and in the right
group) :)


Well since you're talking about OO design a Java group might not be the
best place. Try comp.object
 
W

weer1

Hi,

Sorry, but the comp.object didn't really get me where I wanted to go. I
was there. Your answer was much more appropriate.
Am I reading correctly that Hero is a subclass of GameObject, Race, *and*
Class? Remember that inheritance models the "is a" relationship. Seems
to make more sense to me that a Hero "has a" (composition) Race and
Class.

Yes, you read it right. I was using triangle-arrows (generalisation).
I guess you are right: "A hero _has_a_ race and _has_a_ class."
Okay, that cleared it up. Now I've got: Hero has a race. Hero has a
class. Hero is a GameObject. I've got one last question though, if I
may.

I want to implement 'actions'. This could be hard to design, but I
thought it had to be possible. Actions play an important part in the
game.

Every Spell, Ability and Relic triggers an Action in the game. An
Action plays a sequence of manipulating data in the database over a
certain timing-period.

A spell triggers(?) an action. (interface or something?)
An ability triggers(?) an action. (interface or something?)
A relic triggers(?) an action. (interface or something?)
A relic is a GameObject.

1. Is this right, or can we say that a spell/relic/ablty _is_an_
action?
2. Do I need to make Action a class anyway? It sounded like
methods/operations to me at first.

Please help!

Regards
Weerius
 
Z

zero

(e-mail address removed) wrote in
I want to implement 'actions'. This could be hard to design, but I
thought it had to be possible. Actions play an important part in the
game.

Every Spell, Ability and Relic triggers an Action in the game. An
Action plays a sequence of manipulating data in the database over a
certain timing-period.

A spell triggers(?) an action. (interface or something?)
An ability triggers(?) an action. (interface or something?)
A relic triggers(?) an action. (interface or something?)
A relic is a GameObject.

1. Is this right, or can we say that a spell/relic/ablty _is_an_
action?
2. Do I need to make Action a class anyway? It sounded like
methods/operations to me at first.

Please help!

Regards
Weerius

Triggering an action sounds good to me. Much like the Java awt and swing
GUI objects that respond to user actions, an action class would then
maintain a list of "listeners" that get notified when an action is
triggered. Depending on the design you can then use an interface to
describe what methods (such as triggerAction) an action needs, or just have
a generic action superclass.

Using an action class rather than a method means you can keep a list of all
GameObjects in the vicinity that need to be notified, as well as maintain
other relevant data such as a time period for the effect, the range, ...

As a side note, if you're using Java I'd stay away from class names as
Class or Action. Both are frequently used java core resp. swing classes.
Although packages can solve any scope problems it could still be confusing
to anyone reading your code.
 
W

weer1

Ok, thanks.
I'll implement the action-class. It will have some lists, methods etc.

Best regards
weerius
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top