Board Games
Many board games involve moving around in 2 dimensions on a playing
board.
For example, the Game of Life board is shown below (at least part of it).
At each position on the board, something happens. It might involve
winning
or losing money, moving to a different location, etc.
Starting with a 2-Dimensional array of positions (Buttons), we can create
a board game that plays by the rules that we choose to program.
Moving
Suppose you start at location [2][4]. Then you can move left,
right, up or down.
Those are locations [2][3] , [2][5] , [1][4] or [3][4].
To move right: col = col + 1
To move left : col = col - 1
To move up : row = row - 1
To move down : row = row + 1
Rules
Some locations might be "blocked" or "forbidden".
This information can be recorded in the button - for example, label = "-"
Or it can be permanently recorded in the program -
if( newRow == 5 && newCol == 3)
{ output("This place is forbidden"; }
Another way to block a move is to mark the button with :
.setEnabled(false);
There might also be "holes" in the position grid, where Buttons simply don't
exist -
buttons[5][3] = null ; // this
destroys a Button
Activities
As shown in the game of life, there might be something that
"happens"
on a specific square. For example :
- player must roll dice and get a high number, otherwise they are punished
- player must answer a question correctly to receive a reward
These things can be programmed with specific Java commands, like:
if( row==5 && col == 3)
{ int ans = inputInt("What year was FIS
founded?";
if(ans == 1961)
{ money = money +
1000; }
else
{ output("You must go
back to the start.");
row = 1;
col = 1;
}
return;
}
These activities might be clearly stated on the squares,
or they can be "surprise" events, marked with ???.
Disabled After Use
It might be sensible to disable a square after it has been used,
especially if it involves a very simple question or a lot of money.
- buttons[row][col].setEnabled(false);
Resetting Other Players
In many board games, you can "reset" another player by landing on
the
same square where that players piece is located. Then that sends the
player back to "start".
Winning
Most board games require the player to reach the "end" square to
finish.
Other possibilities are:
- earn a lot of money, like a million Euros
- collect specific objects
- killing all the enemies
Enemies
Games usually have several players. There might also be
"enemies" -
evil monsters that can hurt a player. Players might "battle" with the
enemies
when they contact them. If they win a battle, it can destroy the enemy.
If they lose against the enemy, they can be punished by:
- losing a "life"
- losing money
- be sent back to start
Project
Your project is to create a board game, using either Buttons or Labels
to identify the positions on the board. You must decide on the rules
of your game. Your game could have a "story" - for example, the
players are lost in outer space and must find their way back to earth.
Or they must navigate a shopping mall, buying useful items along the way.
The game should start with an explanation, telling the story and/or rules.
Then the board appears and the player(s) can move around the board
by clicking on a position next to the current position.
The program should include any or all of the following features:
- shows the rules and/or story at the beginning
- shows a 2D board of positions marked with Buttons (or Labels)
- player can move from one position to a neighboring position
- program prevents illegal moves (jumping to far) and correctly
performs legal moves
- at many positions contain "activities" (as described above)
- some positions are labelled to show their activity,
other positions have hidden (secret) activities
- some squares make the player "jump" to some other position
- there are "properties" like lives, money, health, points, collected items,
and the program correctly keeps track of these properties
- there is a way to win or finish the game
- there are some evil enemies to fight against
- there are multiple players
- any other good ideas that make the game FUN and CHALLENGING
You don't need to do ALL of the things described above, but the more
you do the better. In any case, the game must be FUN and CHALLENGING.