Scratch game making tutorial 152

DJ

In this tutorial you will create DJ mixing desks that allow you to play, cross-fade, scratch and select different sound/loops.

 

 

Complete these steps ..

 

1. Open Scratch, OR create a new game (from the top menu choose "File>New").

 

 

2. Select the cat sprite, and then right-click to delete it.

 

 

3. Download and save the following background image ..

 

Now select the Stage, then it's Backgrounds tab, then click Import to import the image ..

 

You can delete the default white background image.

 

 

4. Create the following variables for your game (select "for all sprites") ..

 

Turn off all variables except for Cross-fader, then on the stage do this ..

  1. Drag the cross-fader variable display here ..
  2. Right-click the Cross-fader variable and select "slider"
  3. Right-click the Cross-fader variable again and select "set slider min and max"
  4. Check that it is set to Min:0 and Max:100

 

When the Cross-fader variable is at 0, the player will hear only sound file/loop A.

When the Cross-fader variable is at 100, the player will hear only sound file/loop B.

When the Cross-fader variable is at 50, the player will hear both sound file/loop A and sound file/loop B.

 

Here's what these variables are for ..

Variable name Purpose
Cross-fader This allows the volumes of the 2 decks to be calculated and set
Record A playing? This lets other scripts know if a record/audio file/loop is currently playing on turntable A
Record B playing? This lets other scripts know if a record/audio file/loop is currently playing on turntable B
Which record A? This other scripts know which record/audio file/loop is currently selected for turntable A
Which record B? This other scripts know which record/audio file/loop is currently selected for turntable B

 

 

 

5. Add these scripts to the stage ..

 

 

6. Download and save the following sprites ..

 

Now use the "Choose new sprite from file" button to import them ..

 

 

7. Use "File>Save as" to name and save your game. Name it "DJ" ..

 

 

8. Select the Start/stop A sprite and add all these scripts. You don't need to add the comments, they are just there to explain what each script does ..

 

 

9. You cannot test your game yet, you need to complete more scripts.

Use "File>Save" to re-save it ..

 

 

10. Download and save the following sounds ..

 

Now, select Start/stop button A's sound tab and import HipHop.wav and DrumMachine.wav ..

 

There are 4 sprite buttons to choose these sounds/loops, A1, A2, A3, A4. You will need to add 2 more of your own sounds/loops to use all 4 buttons.

These sounds must be imported to the Start/stop button sprites to play.

 

 

11. We need to do the same for the Start/stop B sprite.

Select the Start/stop B sprite and add all these scripts (you can duplicate and then edit the Start/stop button A scripts) ..

 

 

12. You still cannot test your game yet, you need to complete more scripts!

Use "File>Save" to re-save it ..

 

 

13. Now, select Start/stop button B's sound tab and import HumanBeatbox1.wav and Jungle.wav ..

 

Again, there are 4 sprite buttons to choose these sounds/loops, B1, B2, B3, B4. You will need to add 2 more of your own sounds/loops to use all 4 buttons.

These sounds must be imported to the Start/stop button sprites to play.

 

 

14. The player will not only be able to play 2 records and cross-fade between them, but also grab the records as they are spinning and scratch them.

Select the Record A sprite and then it's Sounds tab, then import Scratch1.wav ..

 

 

15. Switch to the Scripts tab and add these scripts ..

 

 

 

16. Use "File>Save" to re-save your game ..

 

 

17. Select the Record B sprite and then it's Sounds tab, then import Scratch1.wav ..

 

 

18. Switch to the Scripts tab and add these scripts ..

 

 

19. Use "File>Save" to re-save your game ..

 

 

20. You now need to add the scripts to all the button sprites (A1, A2, A3, A4, B1, B2, B3, B4) which are used to select which sound file/loop plays.

Add the scripts to each button sprite ..

 

IMPORTANT: If you add your own sounds to the A3, A4, B3, and B4 buttons you must add their names to the "Which record A/B ? =" scripts.

 

 

21. Use "File>Save" to re-save the game ..

 

 

22. Finally you can test your game!

Go full screen and then press the "B" key on your keyboard.

When you are ready exit full-screen, and then press the "E" key to end your game.

 

 

23. Well done, you've finished making the game! Can you improve it with your own sounds and ideas?