Scratch
Easy
60 mins
140 points
What you need:
  • Computer/laptop

Sound effects

Sound effects are a great way to improve a game or story. In this baseball game we'll add in sound effects for hitting the ball and the crowd.

1 - Create a new Scratch project

Create a new Scratch project and delete the cat sprite.

2 - Add the Baseball 2 backdrop

Ass the Baseball 2 backdrop from the backdrop library.


3 - Add and code the Batter sprite

Add the Batter sprite from the sprite library and then add the following code to make her swing bat when you press the space bar.

when green flag clicked go to x (169) y (37) switch costume to [batter-a v] // start with this costume when [space v] key pressed switch costume to [batter-b v] wait (.1) seconds switch costume to [batter-c v] wait (.1) seconds switch costume to [batter-d v] wait (.1) seconds



4 - Add and code the Baseball sprite

Add the Baseball sprite from the sprite library and give it the following code to set it up for the start and make it move towards the batter.

when green flag clicked show set size to (25) % go to x (-210) y (45) // the middle of the left hand side forever change x by (10) // make it move to the right end



5 - Detect a hit

When the ball touches the bat we will play a hit sound. To detect if the ball touches the bat we will use a touching color   ? block and use the colour of the bat.

Add the following code to the Baseball sprite, underneath the change x by 10  block. 

when green flag clicked show set size to (25) % go to x (-210) y (45) forever change x by (10) // add new code under here if < touching color (#ffc800) ? > then end end


Join our club 😃

To view the remaining 4 steps and access hundreds of other coding projects please login or create an account.

Copyright Notice
This lesson is copyright of Coding Ireland. Unauthorised use, copying or distribution is not allowed.

Scratch is developed by the Lifelong Kindergarten Group at the MIT Media Lab. It is available for free at https://scratch.mit.edu
🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more