Step 5: Creating Initial Fish Behavior

Goal:


Let’s code what happens when the fish touches the shark.

First we want to give our player one point and then make the fish disappear.

Then after one second the fish will go to a random spot on the game screen and reappear.

Steps:

  1. Now click on the “Fish” sprite.
  2. From Events, add a block for when green flag clicked.
  3. From Control, add a forever block and an if statement block.
  4. From Sensing, add a touching mouse-pointer block and change it to touching “Sharky”.
  5. From Variables add a change by block and set it to Points: and set the number to 1.
  6. From Looks, place a hide block.
  7. From Control place a wait 1 second block.
  8. From Motion, place a go to x/y block.
  9. From Operators, place two pick random block inside the go to x/y block and set it to -200 and 200.
  10. From Looks, place a show block.

Code: