dj (dino plugin)

Created: Sep 30, 2022Published: Mar 28, 2023Last modified: Apr 25, 2023
Word count: 105Backlinks: 5

A Dino addon.

---

I'm really out of my depth on music in games, but I love the idea of making something from scratch.

Probably the advice is find some free assets and give credit

  • that's what I've done so far.

But it feels less personal, and I think music should be personal. As long as it gets out of that sounds-like-shit phase.

DJ SoundMap usage

When implementing Gunner and Tower, I used a large map like:

extends Node

func _ready():
        setup_sounds()

###########################################################################
# sounds

onready var sounds = {
        "fire":
        [
                preload("res://assets/sounds/laser1.sfxr"),
                preload("res://assets/sounds/laser2.sfxr"),
        ],
        "jump":
        [
                preload("res://assets/sounds/jump1.sfxr"),
                preload("res://assets/sounds/jump2.sfxr"),
                preload("res://assets/sounds/jump3.sfxr"),
        ],
        "pickup":
        [
                preload("res://assets/sounds/pickup1.sfxr"),
        ],
}
var sound_map

func setup_sounds():
        sound_map = DJ.setup_sound_map(sounds)

func play_sound(name):
        if name in sound_map:
                var s = sound_map[name]
                DJ.play_sound_rand(s, {"vary": 0.4})
        else:
                Debug.warn("no sound for name", name)

func interrupt_sound(name):
        if name in sound_map:
                for s in sound_map[name]:
                        if s.is_playing():
                                s.stop()

This lets you play sounds with just:

GunnerSounds.play("fire")

It randomly selects a sound, and randomly modifies the pitch.

> TODO update this example to reflect the latest


Backlinks

A Dino game.

---

My entry for the godot wild jam #52

What to do when we're not in an active game jam?

A Godot monorepo full of games, addons, and scripts.

A Dino addon.

---

I landed on Hood for all things HUD.

You can count on it to grow in some funky ways!

Next feature is likely a dev-and-player-facing DJ menu.