Instructions
to a Client Programmer:
How to Implement Another
Game
With our object-oriented
game architecture (ooga), implementing another game of your choice is easier
than ever!
Our architecture works best
with grid-based games that deal with playing boards.
How to go about implementing
your own game:
4 Easy Steps!
Step
#1: Implement a GameModel.
Think about the rules of
the game. They should be totally encapsulated in the game model.
The GameModel
has:
All of these items are
protected variables and any object that extends GameModel needs to initialize
them in the constructor and then the object can have access to any of these
variables.
Constructor(..)Step #2: Create A GamePiece
A constructor of some sort should be implemented if you want your game to be playable!Object clone()
for the cloneable interface, allows for the GameModel to create a copy of itselfvvoid newGame()
Resets the model's state to the beginning game statusvoid processClick(int col, int row)
Process a click that occurred on the space (row, col) on the PlayingBoardvoid processClick(Move m)
Process the move, mvoid updateGameStatus()
Updates the status of the current game
Step
#3: Register your class in our GUI
Once your game has been
created, it needs to be registered in the GameSuiteFrame menu.. Because
our GameGUI is generic, you do not need to make any changes to the GUI.
This makes creating a new game blissfully simple.
Modifications to the code in GameSuiteFrame.java:
public void createMenuBar()This line of code adds a new menu option for you game on the main menu. The first parameter for createGameMenuItem is a new instance of the game model and then second is the picture that the menu will display if you want it to.
{
..
..
..
newGameMenu.add(createGameMenuItem((new MemoryModel(5), new ImageIcon("Memory.png")));
..
>>newGameMenu.add(createGameMenuItem((new newGameModel(), new ImageIcon("newGame.png")));<<
..
..
}
Step
#4: You may Need Helper Classes
You may need helper classes
for your gamemodel. For example, in Boggle, we used Professor Astrachan's
trie, jogglereader, joggleword finder classes. For other games, we had
smaller classes that dealt with functions that were particular to a type
of game. For instance, in boggle, we created a dice class and a collectionofdice
class. The Dice class used a random generator to randomly generate a number
which corresponded with a letter, so that each of boggle's lettergamepieces
would return a randomly generated facevalue every time a boggle playing
board was created. You may need to create classes that are small and struct-like.
As a client programmer, this is your call and, of course, there is no right
answer.
Suggestions for future games that could be implemented:
Back to Top