- 1. Getting Started with OdyC
- 2. Naming Your Game
- 3. The Hero
- 4. How to Draw?
- 5. The Map
- 6. Dialogues
- 7. Sound in the Game
- 8. Advanced Template Parameters
- 9. Camera Control
- 10. Integrating Events
- 11. Event Target Manipulation
- 12. Dynamic Hero Modification
- 13. Modifying a Cell
- 14. Global Model Modification
- 15. Orchestration of Dialogues, Sounds, and Endings
- 16. Dynamically Loading Maps
Integrating sound effects into your game can greatly enhance the user experience by adding an immersive and interactive dimension. To do this, you need to use the sound
parameter in combination with the createSound
function.
The createSound
Function
The createSound
function accepts several types of parameters to generate sounds in your game.
-
Predefined Sound Type: You can choose from several predefined sound types, such as:
DEFAULT
RANDOM
PICKUP
LASER
EXPLOSION
POWERUP
HIT
JUMP
BLIP
FALL
FART
-
Seed: An optional number that allows you to generate a specific sound deterministically. Each seed produces a unique sound, and if you want to obtain the same sound in every game session, you just need to reuse the same seed. If no seed is provided, a different random sound will be generated each time the game is launched.
Example of assigning a sound to the X
element:
Using a URL for a Custom Sound
It is also possible to generate sounds using a URL from the PFXR interface. This option allows you to create a complex sound using the graphical interface and reuse it directly in your game.
Example of using a URL for a sound in a template:
Creating a Custom Sound with a Sound
Object
You can also create more complex or custom sounds by passing a Sound
object instead of a predefined sound type. For example:
For more details on sound customization, you can refer to the official PFXR documentation.
- Global Game Volume: The overall volume can be controlled using the
volume
parameter. It accepts a value between 0 (muted) and 1 (maximum volume).
Loading editor...
createGame({ player: { sprite: ` ...99... ...88... .000000. 0.0000.0 8.0000.8 ..3333.. ..3..3.. ..0..0.. `, position: [4, 4], }, templates: { X:{ sprite: ` ..5555.. .5....5. 5......5 5......5 5......5 5......5 .5....5. ..5555.. `, }, }, map:` ........ ........ ........ ........ ......X. ........ ........ ........ ` })