History of
versions of this document.
NN/NN/NN K. Peters: Initial draft
NN/NN/NN K. Peters: Refined;
Layout package modified extensively
NN/NN/NN E. Braun: reviewed
NN/NN/NN K. Peters Revised,
incorporating comments by R. Bostwick
NN/NN/NN K. Peters: moved
details of classes to section 3
5. May 2000 Update: Eric Braude and Tom van Court.
Reworked to reflect lessons learned by implementing
previous version.
25. July 2004 Update: Živana
Komlenov (
This document describes the
packages and classes of a framework for role-playing video games.
This framework covers
essentials of role-playing game classes. Its main intention is to provide an
example of a framework for educational purposes. It is not intended as a
framework for commercial games since its size is kept small to facilitate
learning.
Framework: a collection of
interrelated classes used, via inheritance or aggregation, to produce families
of applications
RPG: Role-playing game - a
video game in which characters interact in a manner which depends on their
characteristics and their environment
Braude, E. J., Software Engineering: an
Object-oriented perspective
UML: The Unified Modeling
Language User Guide by G. Booch, J. Rumbaugh and I. Jacobson, Addison-Wesley Pub Co; ISBN:
0-201-57168-4
IEEE standard 1016-1987
(reaffirmed 1993) guidelines for generating a Software Design Document
The framework consists of
the RolePlayingGame, Characters, Artifacts,
and Layout packages. These are decomposed into the classes shown in figure 5.48.
Figure
5.48 RPG Framework for Role-Playing Video Games
The classes in these
packages are explained below. Unless otherwise stated, all classes in these
packages are public. As indicated by the (UML) italics notation, all of the
framework classes are abstract.
This package is designed as
a state-transition machine. The concept is that a role-playing game is always
in one of several states. This package makes it possible to describe the
possible states of the game, and the actions that can take place in response to
events. It implements the State design pattern (see [Ga]). The state of the game is encapsulated (represented)
by the particular GameState object aggregated
by the (single) RPGame object. This aggregated
object is named state. In other words, state is an attribute of RPGame of type GameState.
The function handleEvent() of RPGame
is called to handle each event occurring on the monitor (mouse clicks etc.). It
executes by calling the handleEvent() function of state. The applicable
version of handleEvent() depends on the particular subclass of GameState that state belongs to.
This package contains the GameCharacter class, which describes the characters
of the game.
This package describes the
physical environment of the game. Each connection object aggregates the pair of
GameArea objects which it connects.
This architecture allows for multiple connections between two areas.
Each GameArea
object aggregates the game characters that is contains (if any), and can detect
encounters among characters.
This package is intended to
store elements that are to be located in areas, such as trees or tables, and
entities possessed by characters, such as shields and briefcases.
The framework does not
involve concurrent processes.
The only dependency among
the framework modules is the aggregation by GameArea
of GameCharacter.
All classes in these
packages are public, and thus the interfaces consist of all of the methods in
their classes.
All mouse events are
listened for by objects of the class RPGMouseEventListener,
which inherits from MouseListener, as shown in figure 6.50.
Figure
6.50 Detailed Design of RPGame (Role-Playing Game)Package
Each object which is
sensitive to mouse events asks an RPGame
object to handle the event. RPGame passes
control to the handleEvent() method of its aggregated GameState object. The sequence diagram for this is
shown in figure 6.51.
Figure 6.51 Sequence Diagram for Handling Mouse Events
For the current release, the
methods are either trivial, or are shown in the figure.
This section elaborates on
section 3.1.2 of this SDD.
There is one class in the Character
package: GameCharacter.
Methods of GameCharacter
setName().
Preconditions:
none; Postconditions: none; Invariants: none
Its
pseudocode is as follows.
IF aName parameter OR maxNumCharsInName() make no sense
Set name to default
value and show this in system window
ELSE
IF parameter string
too long
truncate at maxNumCharsInName()
ELSE assign the
parameter name
This package is described
completely in section 3.1 of this SDD.
[Not applicable in this
iteration.]