This is the design bible for the group project involving the following people:
Direct any corrections, additions or complaints to me (Josh). Also, it is anticipated that this page will be highly superfluous once the program is integrated. Its main purpose is to show how other people's modules work before they do work, so we can all start slinging code real soon.
The following small picture demonstrates the big picture of how the modules fit together (the hooks, or links between modules, are expanded on below):
People responsible for each module are:
The game state is the centre of the program, so is fairly well-defined. The general design is (I've drawn the UI object in to show it has a pointer to the Universe):
The methods shown are those that may be useful to some other module. I will expand on their proposed function for completeness (some of this is a bit pedantic, but you will understand that it is good to know exactly what to expect from someone else's function):
| Thing |
|
|---|---|
| Player |
|
| MazeWorld |
|
| Room |
|
A minimal design of the Data Storage module looks like this:
The getUniverse() method will return a Universe object with state for a new game. The getUniverse(File) method will return a Universe object with state for a game loaded from the given file. The saveUniverse(Universe, File) method will save the given Universe's state to a file.
The Data Storage module must also be able to load a PictureMap from a directory structure, to be used by the Renderer module. The getPictureMap() method will facilitate this. A PictureMap simply contains a map from resource names of Thing objects to Picture objects. Exactly what a Picture object is is still unclear, due to Josh being lazy.
There are two main "technologies" used on the interface between modules. They are the Interaction interface, and the RoomListener interface.
Interactions are classes that describe a way in which the user can interact with a Thing object. They are characterized by having a "name" field and a do() which may take some sort of argument and returns a message as a String to be displayed by the User Interface. A proposed hierarchy looks like:
The idea is that all of these classes are abstract, and when an item wants to support an interaction it will make an inner class on the fly within its getInteractions() method. On the User Interface end, the user will be asked to select an interaction from the list and a sequence of instanceof statments will determine which type of interaction was chosen, and hence determine what must be required from the user.
The set of these abstract classes, while resembling the structure above, will no doubt be added to often throughout the development of the program. This is a crucial point of communication between the Game State and the User Interface developers.
This is the device by which the RenderingFrame sends messages to the User Interface module. It mimics the Event model in the Java API.
The RoomEvent object could conceivable get more complex as the need arises, but for intial purposes it will contain a Thing that the user has clicked on. (The logical thing for the User Interface to do with this information is to process interactions on the received thing.)
Here is some example code that should be demonstrative of what each module knows, and how everything gets started.
public class AdventureGame {
Universe universe;
DataReader reader;
UI ui;
// New game
AdventureGame(UI ui) {
this.ui = ui;
reader = new DataReader();
universe = reader.getUniverse();
ui.setPictureMap(reader.getPictureMap());
ui.startGame(universe);
}
// Load game
AdventureGame(UI ui, File f) {
this.ui = ui;
reader = new DataReader();
universe = reader.getUniverse(f);
ui.setPictureMap(reader.getPictureMap());
ui.startGame(universe);
}
}
public class UI {
...
public static void main(String[] args) {
UI ui = new UI();
ui.displayTitleScreen();
}
public void actionPerformed(ActionEvent e) {
if(e.getActionCommand().equals("Play")) new AdventureGame(this);
if(e.getActionCommand().equals("Load")) new AdventureGame(this, getFileFromUser());
}
}
This is a list of all of the proposed helper classes that are mentioned somewhere above, and are concerned with multiple modules. I (Josh) will write these, I suppose.