Step 6: Skins
Unless a
Skin is defined at creation, one will be selected at random. There are three
Enemy skins.
Random(3) generates a random value between 0 and 2. By adding 1, the value is between 1 and 3.
- Skin of
= 0
: Set Skin to Random(3)+1
Earlier, depending on the
Direction string, we set the animation direction to either 0 (right) or 16 (left). Now we will add the
Skin value to the animation direction value. This will display the appropriate skin.
: Set direction to Dir( "
" )+Skin( "
" )-1
For example, when an Enemy is given a random Skin value of 3, the animation direction will be set to either 18 (16+3-1) or 2 (0+3-1) and this is where the cop skin is stored.
9