Snap Projects, March 2, 2012, Cardinal Forest Elementary School
Snap website
Snap is available online - about Snap.
back to more Snap! projects
- Bounce Game Snap!
Part 1: Set up the game board
Make a variable from the "variables" menu
- Name the variable "xmax"
- Create variables for "xmax", "ymax", "xmin", "ymin"
- Set variable "xmax" to 150.
- Set these values for xmax, ymax, xmin, ymin: 150, 150, -150, -150
- Hide these variables. Use a 'clear' and 'penup' block. Use a 'go to' block to go to xmax, ymax
- Set pen size to 10 for a thick line. Choose the purple pen color.
- Go to the following x and y positions for the corners of the game board:
- Set the pen size back to 1, and choose a blue pen color.
- Make a variable "angle" for the angle of motion of the turtle sprite.
- Set the variable angle to a random number from 0 to 360
- Point in the direction of this random angle.
- Put the pen down.
- Run these blocks by clicking on the top block. This will check what the blocks are doing.
Part 2: Make a block named "setup"
- Choose "Make a block" from the variables menu. Use the "motion" blue category. Name the block "setup"
- Drag all of your blocks into this new block definition:
- 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.
- Make a new block. Use the blue "motion" category. Name the block "bounceGame".
- Make one input variable called "numMoves".
- 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.
- Drag in an "if" block. Also use an operator green block for "greater than" : >
- Drag in "x position" for the first part of the 'if' block.
- Use the block "xmax" for the second part of the "greater than" comparison green block.
- If the x position is greater than xmax, set a new value for the 'angle' variable.
- Set the new value of "angle" to -1 * angle. Use another green operator block, for multiplying: "*"
- Point in the direction of the new angle.
- 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!
- Try adding something of your own to this program. Change the size of the game board. Think of other creative changes you can make.