Snap Projects, March 2, 2012, Cardinal Forest Elementary School

Snap website

Snap is available online - about Snap.

back to more Snap! projects

  1. Bounce Game Snap!

    Part 1: Set up the game board

    Make a variable from the "variables" menu

  2. Name the variable "xmax"

  3. Create variables for "xmax", "ymax", "xmin", "ymin"

  4. Set variable "xmax" to 150.

  5. Set these values for xmax, ymax, xmin, ymin: 150, 150, -150, -150

  6. Hide these variables. Use a 'clear' and 'penup' block. Use a 'go to' block to go to xmax, ymax

  7. Set pen size to 10 for a thick line. Choose the purple pen color.

  8. Go to the following x and y positions for the corners of the game board:

  9. Set the pen size back to 1, and choose a blue pen color.

  10. Make a variable "angle" for the angle of motion of the turtle sprite.

  11. Set the variable angle to a random number from 0 to 360

  12. Point in the direction of this random angle.

  13. Put the pen down.

  14. Run these blocks by clicking on the top block. This will check what the blocks are doing.

Part 2: Make a block named "setup"

  1. Choose "Make a block" from the variables menu. Use the "motion" blue category. Name the block "setup"

  2. Drag all of your blocks into this new block definition:

  3. Drag in your setup block that you created. Click on the block to check that it works the way you expect.

Part 3: Create a "bounceGame" block with 1 input variable.

  1. Make a new block. Use the blue "motion" category. Name the block "bounceGame".

  2. Make one input variable called "numMoves".

  3. Use a repeat block. Drag "numMoves" into the repeat block. This is a variable, you set this value when you run your program. Also put in a move 2 steps block.

  4. Drag in an "if" block. Also use an operator green block for "greater than" : >

  5. Drag in "x position" for the first part of the 'if' block.

  6. Use the block "xmax" for the second part of the "greater than" comparison green block.

  7. If the x position is greater than xmax, set a new value for the 'angle' variable.

  8. Set the new value of "angle" to -1 * angle. Use another green operator block, for multiplying: "*"

  9. Point in the direction of the new angle.

  10. Finish the definition of this 'bounceGame' block with these other 'if' blocks. Some of this math is beyond the scope of this course. It is Trigonometry!

  11. Try adding something of your own to this program. Change the size of the game board. Think of other creative changes you can make.