EXAMPLE
In
this example, we will look at the steps used to create a simple text-based
adventure game.
STEP 1 – A STARTING MAP
One
important aspect for the game is to remain very organized. Since my game will have the character
move from location to location, a map helps keep things organized. The map below shows all of the possible
locations in the game and the lines show the possible pathways that can be
followed.
STEP 2 – GAMEPLAY
We
now need to figure out how we will move from location to location and solve
quests. I am opting to make the game
a little easier by providing a description of the location with keywords
that are capitalized. The keywords
are the possible input values that the user can use.
Below
is my first location description. The
player's choices are DRINK, OLDHOUSE, BRIDGE and FARM.
You wake up with a sharp headache. You are confused. Uncertain of who or where you are. You see a well nearby. You consider taking a DRINK. There is also an OLDHOUSE in the
north. To the south, you see a
path that leads to a BRIDGE. To
west, there seems to be a FARM.
And to the east, a MINE.
|
STEP 3 – GAME STATE
It
will be important to keep track different things such as items acquired,
conversations that have taken place and locations that I have visited. I will simply keep a variable for each of
these and set it to true or false as required. All of these variables will be stored as
data fields inside a single class called GameState.
For
example, at one point, I will need sword, I will need to get training
permission and I will need to get the actual training for it. All three of these are going to have
their own variable as such:
public boolean hasSword = false;
public boolean canTrain = false;
public boolean hasSwordTraining = false;
STEP 4 – GAME LOOP
The
loop is quite simple. Using the
game's state, we display the appropriate location description. Then, we wait for the user's response and
use it to update the game state.
Here
is pseudocode the main method in the main game class.
Loop
{
Display description based on state
Get user input and update state (end
game if necessary)
}
STEP 5 – START BUILDING
Now
we simply start developing each possible location adding to the game's
state possibilities as needed. Of
course, this can take hours and hours to do and each addition adds a lot of
the game's complexity – so remain organized!
|