Treasure
Hunter Program
Version
2.0
Background: This program builds on your previous version
of Treasure Hunter (1.0). If you do not
have version 1.0 done yet, see the details for Treasure 1.
Overview: In this version, you will make the game
dynamic so that the user can choose to move up, down, left, right, quit, or ask
for help.
Specifics:
- Adjust your Get Starting Point subroutine to ensure that valid data is entered for the row and
column. Do not allow the user to
enter a starting row or column outside the valid range (rows = 1 - 24, columns = 1-80).
- Adjust your subroutine
called get.command. The get.command subroutine should ask the
user for their command choice (U, D, L, R, Q or H).
U
= Up
D
= Down
L
= Left
R
= Right
Q
= Quit
C
= Clue
H
= Help
The
user is allowed to enter a choice, but it must be a valid letter (allow for
upper or lower case). You DO NOT
need to react to their choice in this subroutine. Clear the screen after they’ve entered a
valid command.
- Add another new subroutine
called handle.command. This subroutine reacts to the command
entered by the user. The
subroutine should essentially be a big IF structure. The structure should do one thing if the
user entered U, another if the user entered D...etc.
- Add another new subroutine called bury.treasure. This subroutine determines a random row and column for the treasure. Include a RANDOMIZE TIMER statement in this subroutine so that the treasure is "buried" in different locations each time the game is played.
- Finally
adjust your main program. The idea is to show the title screen,
show the directions/help screen, bury the treasure, and then get a
starting location. After you’ve
finished these four starting tasks, you show the hunter on the
screen, get a command, and handle the command. Then, you show the hunter again (maybe
in a different location), get another command, and handle the
command...etc. This continues until
the user decides to quit. (In this
version of the game, there is no way to “win” or find the treasure.)
Program flow:
title.screen
directions/help
bury.treasure
get.starting.point
do
show.hunter
get.command
handle command
loop until the user quits