Game Development Reference
In-Depth Information
Adapting to the skills of the player— Changing the speed of the timer can
make a level much easier or harder. You could extend the game so that in
some cases the timer would stop, or move back a few seconds if the player
picks up a special item. You could even make the level progression adaptive,
so that if the player dies too often, the maximum time of 30 seconds per level
is increased. However, you should watch out with this. If helping the player is
done in a too obvious way, the player will realize it and adapt his/her strategy
to it (in other words, the player starts playing worse in order to make the levels
easier). Also, the player might feel he/she is not treated seriously. A better way
in this case to deal with adapting the maximum time per level is by allowing
the player to (partly) transfer time left over from previous levels to the current
level. That way, difficult levels can be made easier, but the player has to do
something for it.
30.2.2 When the Timer Reaches Zero...
When the player does not finish the level on time, the bomb explodes, and the game
is over. We added a boolean member variable to the Player class that indicates if the
player has exploded. We then add a method called Explode to the class that sets the
explosion in motion. This is the complete method:
public void Explode()
{
if (!isAlive || finished)
return ;
isAlive = false ;
exploded = true ;
velocity = Vector2.Zero;
position.Y += 15;
this .PlayAnimation("explode");
}
First off, we cannot explode if we were not alive in the first place, or if we finished
the level. In either of those cases, we simply return from the method. Then, we
set the alive status to false and the exploded status to true . We set the velocity to
zero (explosions do not move). We slightly increase the y position to better align
the explosion animation to the character position, and finally, we play the 'explode'
animation. This animation is stored in a sprite sheet and consists of 25 frames of an
explosion animation.
Since gravity also no longer affects an exploded character, we only do the gravity
physics if the player is not exploded:
Search WWH ::




Custom Search