Game Development Reference
In-Depth Information
While we're reviewing the points system, let's add to that as well. The cat loses points when
touched by an enemy. So it should also gain points on hiing an enemy.
1. We copy the
changePoints
funcion from the
cat
sprite to both the
Knight
and
Ghost2
sprites to be able to use it there.
2.
At the end of either of the
clone
scripts, just before deleing the clone, let's reward
points for defeaing the enemy.
3.
For the
Knight
sprite, we award 10 points.
4.
For the
Ghost
sprite, we award 20 points, because it is more difficult to hit the ghost.
Now to prevent the players from uncontrollably pressing the weapon butons, let's deduct
points again for using a weapon. That way, there is a limit to how many imes the weapons
can be used. It will encourage the player to make a deliberate choice and not get into a mad
killing frenzy.
1. We also copy the
changePoints
funcion to both
sword
and
arrow
.
2.
In either of the
() key pressed
scripts, we call the
changePoints
funcion, just ater
we have confirmed the player actually has the item in the inventory.
3.
For each use of an item, we deduct 5 points.