1 / 9

Using MIT Scratch for Programming and Control Exercise 2 Controlling movement with the keyboard

Learn to control sprite movement using keyboard arrows and coordinates in MIT Scratch. Combine keyboard control with previous exercises to allow the sprite to walk around the screen. Edit scripts for different arrow key movements to drive the sprite. Save your work as "catwalk2."

jbishop
Download Presentation

Using MIT Scratch for Programming and Control Exercise 2 Controlling movement with the keyboard

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Using MIT Scratch for Programming and ControlExercise 2 Controlling movement with the keyboard

  2. What you will learn • In this exercise we will learn: • how to control the movement of the sprite with the keyboard arrows using x and y co-ordinates • We can combine this with the previous exercise to make the sprite walk around the screen

  3. Keyboard control • It is possible to control your sprite using the keyboard arrow keys. • There is a small pointer next to the Sprite symbol at the top of the screen which can be set to any angle thereby determining the natural direction of movement of the sprite. • In this exercise we want the Sprite to move exactly up and down vertically or side to side horizontally so we will use the change x by and change y by instructions to order to ensure that the Sprite moves exactly horizontally or vertically

  4. Keyboard control • Before completing this exercise dump your existing script into the left had side of the screen (this will delete it)

  5. Keyboard control • Now copy the main part of the script then edit the sub script for each movement of the mouse determined by each of the respective four arrow keys

  6. Keyboard control • Drop the three new copied sets of instructions inside the forever instruction (not inside the existing If condition instruction) • Click the green flag button. • It should now be possible to drive your cat sprite around the screen using the up, down, left and right arrow keys

  7. Keyboard control

  8. Cat walking with keyboard control • Looking back over the previous exercises it should be possible to make a script combining what you have already learned that allows the Cat sprite to walk around the screen.

  9. Save your work • Save this exercise with the file name catwalk2

More Related