Game Development Reference
In-Depth Information
Colliding with the enemies
If the player touches any of the enemies, the health meter at the top-left corner of the stage is
reduced, as shown in Figure 8-21.
Figure 8-21. When an enemy touches the player, the health meter is reduced.
This is the code in the @qjcakjKja[I]j]can that causes it to happen:
eb$ajaiuKja9jqhh%
w
eb$lh]uan*depPaopK^fa_p$ajaiuKja%%
w
da]hpd*iapan*se`pd))7
y
y
eb$ajaiuPsk9jqhh%
w
eb$lh]uan*depPaopK^fa_p$ajaiuPsk%%
w
da]hpd*iapan*se`pd))7
y
y
Before the meter can be reduced, the code has to check whether the enemy objects are actually on
the stage. You can find out if an object exists by checking whether it has a jqhh value like this:
ajaiuKja9jqhh
The code needs to find out whether the ajaiuKja object exists because if it makes a reference to
an object that doesn't actually exist, the compiler will generate a deluge of errors when the program
runs. The enemy objects can be removed from the game by being shot by the player's bullets, so
there's a chance they might not actually exist at some point. You can't take the chance that the code
might not be able to find them.
 
Search Nedrilad ::




Custom Search