Game Development Reference
In-Depth Information
y
y
ahoa
w
ajaiu*ckpk=j`Opkl$-%7
_khheoekjD]oK__qnna`9b]hoa7
y
++?da_gbknaj`kbc]ia
eb$da]hpd*iapan*se`pd8-%
w
iaoo]ca@eolh]u*patp9C]iaKran7
y
eb$o_kna:91%
w
iaoo]ca@eolh]u*patp9Ukqskj7
y
y
2. Save the I]ej[Lh]ucnkqj`*]o file and test the project. If the lh]uan
object is able to touch the enemy five times before the health meter
runs out, the words You won! display, as shown in Figure 7-17.
In effect you've turned this into a little minigame. Can you touch the owl five
times before the health meter runs out?
Figure 7-17. You can win the
game if you touch the enemy
five times before the health
meter runs out.
Yes, I know, it's not a real game, more of an accidental game, but I'm sure you
can see where you can take it with only a little further refinement.
Of course, this game has some problems. With a little more playing, you can actually cheat and “win”
even if the health meter runs out. Can you think of a way to make what you've built a little more
cheat-proof? (Hint: you'll need another variable and another eb/ahoa statement!) You'll encounter
these sorts of bugs-that-might-be-features-but-are-really-bugs in your games all the time, so now's
a good time for a real-world challenge to sharpen your debugging skills. (The I]ej[Lh]ucnkqj`[1*]o
file contains the complete code for this example.)
Picking up and dropping objects
It's time for the pig and owl to put aside their differences and make peace! In the next example, you'll
see how you can make the pig pick up an apple and carry it to the owl. This is very easy to implement
using the techniques discussed so far in this chapter and it reintroduces a method you haven't seen
since Chapter 3, the cute-as-a-button method named ]``?deh`.
1. You first need an object that the player can carry. Create a new symbol called =llha and design
a simple graphic of an apple. For this technique to be clearly visible, you might want to make
it smaller (half the size or smaller than the lh]uan object).
 
Search Nedrilad ::




Custom Search