Bat and Ball Game
Total Page:16
File Type:pdf, Size:1020Kb

Scratch – Problem Set 3 Page 1 Getting Started Create a new scratch project and save it as pset3. You will solve 2 problems which you will save in this file. Remember to use the 4 steps of Problem Solving 1. Understand problem (decompose) 2. Create solution ("algorithm") 3. Create program ("script(s)") 4. Test program *** be sure it does everything stated in the requirements ***
Problem 1 – Count Down Example Output Write a script that makes your sprite perform a "rocket" count down. 1. Start your character at the bottom of the stage (use Go To block for this). 2. Have the character say each number of the count down (in 1 second increments). (ie: 10, 9, 8…1) Create a variable named counter to keep track of the count. 3. When it is done counting down, have the character say "Lift off" for 1 second. 4. Finally, have the character actually move up the screen and when it reaches the top, have it hide. Hints: Blocks needed
(replace Hello with your variable)
(which one moves a character up ?) Use a Repeat loop that keeps changing the x or y? value by say 10 until you get to the top.
Create Algorithm 1. Show character 2. Go to position ______,______(bottom of screen) 3. Set my counter to ______4. Repeat ___ Times 5. Say ______6. Change my counter by _____ 7. Say ______8. Repeat _____ Times 9. Change ______by ____ 10. ______the character Scratch – Problem Set 3 Page 2 Problem 2 – Play the Alphabet with each Instrument You learned how to play different instruments using loops in Video 8. Create a script that plays all 21 instruments. Have each instrument play the alphabet which is the notes A to G (= 11 Notes: 57 to 67). Say the instrument number (use the Say block with no seconds) before you play the notes. For this program to be efficient, you will want to use Nested Loops.
Your Program Output will thus be: "Instrument 1" play note 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67 "Instrument 2" play note 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67 …. "Instrument 21" playing note 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67
This is what you need your program to do, but it is inefficient code (use LOOPS and VARIABLES !)
This is 13 total blocks for 1 instrument.
You would have 1 copy for each instrument.
Total Blocks = 21 instruments * 13 blocks = 273 blocks
With Loops and Variables we can do this with only 9 total blocks!
DECOMPOSE AND CREATE SOLUTION
As part of the design, you will need 2 variables: 1. instrument - this will keep track of the instrument number you are playing 2. note – this will keep track of the next note to play on the instrument
Very General Algorithm Outline is For Each Instrument (1 to 21) do: Say Instrument number For each note 57 to 67 Play the next note
Create Algorithm
1. set instrument variable to ______2. Repeat ____ -- this loop runs for each instrument 3. say ______4. set instrument to ______5. set note variable to number ______6. Repeat ______this loop runs for each note 7. play note ______8. change note variable by ____(ie: move to next note ie: 57 to 58) 9. change instrument variable by ____ (ie: move to next instrument ie: 1 to 2)