Game Development Reference
In-Depth Information
2.
Between the
startGame
receiver and the
indStartPosiion
block, make sure to
create a
delete <all> of <xySave>
block to start with an empty list, as shown in the
following screenshot:
3. Coninue to deine the funcion we just created. Such a deiniion is just like a
normal stack of script blocks. It can be called whenever we use the funcion block.
4. Our irst addiion to the
deine indStartPosiion
script is to create the
set size to
(15) %
block to make the sprite fit inside the maze.
5. Then, move it to the upper-left corner with a
go to x: (-230) y: (170)
block.
6. Add a
repeat unil
block to check for collisions with the walls.
7. In the condiion slot, place a combinaion of
not touching color <black> ?
. Use the
eyedropper
opion to pick the color.
8. The acion to repeat will be to use the
change x by (20)
block, making the cat step to
the right.
9. Ater the cat has found its staring posiion, use the
add x posiion to <xySave>
(the
built-in variable).
10. Then, set the
add y posiion to <xySave>
(the built-in variable).
11. Make the sprite
go to front
to make sure it isn't covered by other sprites.
12. Finally, make the
show
sprite.