You’ve made a fantastic Puzzle Script game, but now you want to add sounds to it. How do you do it? This tutorial will show you! It assumes no prior programming knowledge except the previous Puzzle Script tutorials I have written.
Open the sample project. Let’s make some sound effects. Underneath the game screen, you will notice black squares with white symbols. These are for sound generation. Each symbol generates a unique type of sound, and the cross clears the sounds you’ve made. Try clicking a few and see what sounds you get.
The yellow numbers are the unique codes that you will copy and paste into your code where you want to use the sounds.
How To Use The Sounds
Once you’ve found a sound you like, you need to do to put it in the Sounds section of your game’s code.
There are a few ways to use sounds. The most basic is to create a new sfx. They must be numbered. You create a new sfx by giving it a number from 0 – 10 then pasting the numbered ID of the sound. In the Sounds list, make a new sfx called sfx0 and assign a sound you’ve generated, like below:
To use an sfx sound, you must put it in the rules of your script after an event. Let’s attach the new sfx0 you created to the event where we destroy a crate (the event is already in the sample project), like below:
(The player destroys a crate)
[ > Player | CrateVanish ] -> [ Player | ] sfx0
Sounds can also be declared to play with certain events, eg:
Crate MOVE 36772507
It plays a sound whenever a Crate is moved. Generate a new sound effect for when you pull CratePull objects and make it play when CratePull moves, like so:
CratePull MOVE 12735307
Event sounds only need to be declared in the Sounds section: they do not need to be mentioned in the rules.
List of Ways to Play Sounds
The following is a list of different Event Sounds you can use, taken from the Puzzle Script documentation.
- Object Action 541566
Plays when an object is subject to the ‘action’ during a turn
- Object Create 641667
Plays when the specific object is created.
- EndGame 5416789
Plays when the game finishes.
- EndLevel 6417822
Plays when you finish a level.
- Object CantMove 781673
Plays when that object unsuccessfully moves, in any direction
- Player CantMove Down Left 464674
Plays when that object unsuccessfully moves, either down or left.
- CloseMessage 344456
Plays when the player closes a message window
- Object Destroy 187975
Plays when an object is destroyed.
- Object Move 264567
Plays when that object successfully moves, in any direction.
- Object Move Down Left 765432
Plays when that object successfully moves either down or left.
- Object Move Horizontal 345367
Plays when that object successfully moves horizontally. Vertical is also valid.
- Restart 7865435
Played when the player presses the restart button (R).
- SFX0 765743
Can be anything form SFX0 to SFX10. These are custom sound events that can be triggered from rules.
- ShowMessage 478483
Plays when a message appears
- StartGame 234626
Plays when you start a new game.
- Startlevel 765436
Plays at the start of every level.
- TitleScreen 876543
Plays when the title-screen is loaded.
- Undo 436234
Plays when the player presses the undo button (Z).
move and cantmove can specify directions, so that certain sounds play if you move in different directions.