Game Development Reference
In-Depth Information
The methods help modularize the program by breaking the steps down into manageable pieces. Let's
go on a little tour of how all this new code fits together.
First, you need to help the game figure out whether the player can still continue playing. You add
the same directive to the first two blocks of the eb+ahoa statement in the kjCqaoo>qppkj?he_g event
handler, highlighted in bold:
eb$_qnnajpCqaoo:iuopanuJqi^an%
w
kqplqp*patp9Pd]p#opkkdecd*'Xj'c]iaOp]pqo7
_da_gC]iaKran$%7
y
ahoaeb$_qnnajpCqaoo8iuopanuJqi^an%
w
kqplqp*patp9Pd]p#opkkhks*'Xj'c]iaOp]pqo7
_da_gC]iaKran$%7
y
ahoa
w
kqplqp*patp9Ukqckpep7
c]iaSkj9pnqa7
aj`C]ia$%7
y
The two new directives are method calls to the _da_gC]iaKran method. So as soon as the program
reads one of these directives, it immediately jumps ahead to the _da_gC]iaKran method's function
definition and runs whatever directives it contains.
This is what the _da_gC]iaKran function definition looks like:
bqj_pekj_da_gC]iaKran$%6rke`
w
eb$cqaooaoNai]ejejc8-%
w
aj`C]ia$%7
y
y
The method checks to see how many guesses the player has remaining. If there are still enough, noth-
ing happens, and the game continues. But if cqaooaoNai]ejejc is less than 1, the game is brought to
an end by calling the aj`C]ia method:
bqj_pekjaj`C]ia$%6rke`
w
eb$c]iaSkj%
w
kqplqp*patp9Uao(ep#o'iuopanuJqi^an''Xj' ±
Epkjhupkkgukq'cqaooaoI]`a'cqaooao*7
y
ahoa
 
Search Nedrilad ::




Custom Search