Game Development Reference
In-Depth Information
Engage thrusters
The knight will behave quite similarly to the cat sprite. It's allowed to move through the
hallways, but it can't pass through walls. That means we can reuse a lot of the scripts
we've already writen for the cat.
1. We drag both the createMaze listener script and the takeStep funcion from the
cat to the Knight sprite to make copies there.
2.
Then, we click on the Knight sprite to switch to its Scripts editor .
3.
To the createMaze listener, we add a set size to () % block and type in 12 .
This makes the knight fit the maze.
4.
At the end of this script, we add a delete this clone block.
You might wonder about this last step. There aren't any clones to delete, and you would
be right. There aren't any clones, not yet at least. However, we will soon write a script to
create them.
However, first we will have a look at the copied takeStep funcion. You may have noiced that
with the funcion xySave , the list has been copied as well. That's a good thing, because we
will need that list. Note that both the cat and the Knight have their own personal version of
the list. When created, it was set to be for this sprite only .
 
Search WWH ::




Custom Search