Squeakland BouncerThis week we will make a ball move around the screen, but stay inside four invisible 'walls'. We will create a script that loops, making the balls move left/right & up/down in steps of 20 pixels (screen dots). A variable is a word that represents a number. We will create two variables called xstep and ystep for the distance the ball should move along the x axis and up the y axis. At each step the script will:
This means when we're adding '20' the ball moves right/up, when we're adding -20 we're moving left/down. Build the script1. Open the 'Supplies' tab and drag an ellipse (oval) onto the screen. 2. Hover over the ellipse to make the handles appear 3. Change its name to 'ball' 4. Open a viewer for 'ball' 5. Select the 'Geometry' menu ('geometry' means shape) and set ball's width and length to 40 6. Drag out a script, call it 'bounce' 7. Add 4 yellow 'test' boxes into the script 8. Click the small 'v' button at the top of ball's viewer to create a 'variable' (a word that represents a number that can be changed). Call it 'xstep'. Create another called 'ystep'. 9. Now build the following script by dragging each part into the test boxes:
Test the script1. Press the clock to 'run' the script 2. Stop the script, select the 'Pen' menu and turn on the pen. Run the script. 3. Stop the script, change the colour. Move the ball and start the script again. 4. Try changing the numbers in the script. What happens? Related pages: Squeakland Category: ICT Author: Mr Kershaw http://bradfordchristianschool.com/SqueaklandBouncer Bradford Christian School, Livingstone Road, Bolton Woods, Bradford BD2 1BT
Tel: 01274 532649 Fax: 01274 595819 |