Game Development Reference
In-Depth Information
Perform the following steps to handle collision with the player:
1.
Start with a
when I start as a clone
block.
2.
Add a
forever ()
block. Then, inside the
forever ()
block, add an
if touching <Player>
? then ()
block.
3.
Inside the
if touching <Player>? then ()
block, add an
if costume # < good_food_
start_cos_idx then ()
block.
4.
Inside the
if costume # < good_food_start_cos_idx then ()
block, add a
broadcast
<bad_food_eaten>
block. In other words, if the player sprite eats a bad food item,
then the food clone sends out a
bad_food_eaten
message.
5.
Place an
else ()
block and inside it, add a
play sound <point>
block. Then, place the
change game_score by ()
and
broadcast <score_updated>
blocks; enter
1
. In other
words, if the player sprite eats a good food item, then they earn one point.
6.
Finally, enable the
delete this clone
block to wrap up collision handling.