Game Development Reference
This chapter will be your first real look at designing a complete game. It's a short,
simple game, but contains all the basic structural elements of game design that you'll
be returning to again and again. Input and output, decision making, keeping score,
figuring out whether the player has won or lost, random numbers, and giving the
player a chance to play again—it's all here. You'll also be taking a much closer look
at variables and eb statements and you'll learn how to modularize your program by
breaking down long segments of code into bite-sized methods. By the end of the
chapter, you'll have all the skills necessary to build complex logic games based on
this simple model.
The game you'll build is a simple number guessing game. The game asks you to guess
a number between 1 and 100. If you guess too high or too low, the game tells you
until you'll be able to figure out what the mystery number is by deduction.
You'll actually build this game in a few phases. You'll start with the most basic ver-
sion of the game, and then gradually add more features such as limiting the num-
ber of guesses, giving the player more detailed information about the status of the
game, randomizing the mystery number, and then adding an option to play the game
Sound like a lot? Each phase of the game is self-contained, so you can give yourself
a bit of a break to absorb and experiment with the new techniques before moving
on to the next phase. You'll be surprised at how easy and simple it is when you put
all the pieces together.