Game Development Reference
In-Depth Information
8.
Next, we need to create a new list named
items
. This list will be available for
all sprites.
9. In the script, we add
sword
to the
items
list.
10. Then, we use the
hide
block to hide the sprite.
When this script completes, the sword has changed places from inside the maze to the
players inventory. When it's in the inventory it can be used as a weapon to defeat enemies.
We will add that funcionality now.
1. We start another script with a
when <s> key pressed
block.
2. Then, we make a check with an
if...
block. Only when this resolves will we take
acion on the key press.
3. We check the
if <items> contains sword
block then we make the sprite
go to <cat>
.
4. Then, we need to create a new variable to save the direcion the cat is facing. We
name this variable
catDir
. It needs to be available for all sprites.