Video Game Design and Coding

PLECK lesson 97 · suggested week 20, day 2

Import a short original audio file

Objective. Use a local AudioStreamPlayer with an explicit play action.

Godot Engine Standard desktop editor 4.7.2-stable, GDScript (Godot 4), Compatibility renderer. Headless Godot 4.7.2.stable.official.ed1daf0bf passed 106 assertions on the supplied scaffolds, including malformed JSON saves. Audio used the Dummy driver and a synthetic WAV, not a speaker. The visual editor, browser export, and signed-in submission were not tested. The desk still does not run a student's own upload.

About 55 minutes. The due date is chosen by a parent.

Original sound, safe levels, activation, mute and licensing

Suggested pace: Recall and predict 5 min; Read instruction and scaffold 12 min; Build or design the assigned artifact 25 min; Run acceptance tests 8 min; Explain and checkpoint 5 min.

Materials: Godot Standard 4.7.2 desktop editor (GDScript, Compatibility renderer), Local course folder and prior checkpoint, No paid assets or public account required.

Comes after VGC-L096.

Use a short original WAV or OGG provided by a teacher or recorded privately with permission. Put it in audio and assign it to an AudioStreamPlayer named Sound as in C-AUDIO. Turn autoplay off and lower volume before testing. Press Play to trigger the sound. Keep recordings free of conversations, names and background private information. If recording is unavailable, use a teacher-provided original sound; recording equipment is not part of the programming requirement.

Worked example

A short original tap sound confirms a collected object while a number changes on screen. Muting the tap leaves all required information visible. Scaffold C-AUDIO — Local audio playback with a reversible mute Setup: Create Control AudioLab with Button Play and CheckButton Mute. Child AudioStreamPlayer Sound: copy the supplied student-support/audio/course-tap.wav into your project audio folder and assign it (or another short original WAV/OGG), autoplay Off, volume_db -12. Attach script to AudioLab. Recording is optional: a teacher-provided original file is equivalent. No microphone or face recording is required and all recording stays private. ```gdscript extends Control func _ready() -> void: $Play.pressed.connect(_play) $Mute.toggled.connect(_mute) func _play() -> void: if not $Mute.button_pressed: $Sound.play() func _mute(enabled: bool) -> void: if enabled: $Sound.stop() ```

Local audio playback with a reversible mute

GDScript (Godot 4, not Scratch, Python, JavaScript or C#). Scaffold C-AUDIO. Copy starts from this text. The desk does not run it.

Scene and node setup

Create Control AudioLab with Button Play and CheckButton Mute. Child AudioStreamPlayer Sound: copy the supplied student-support/audio/course-tap.wav into your project audio folder and assign it (or another short original WAV/OGG), autoplay Off, volume_db -12. Attach script to AudioLab. Recording is optional: a teacher-provided original file is equivalent. No microphone or face recording is required and all recording stays private.

extends Control
func _ready() -> void:
    $Play.pressed.connect(_play)
    $Mute.toggled.connect(_mute)
func _play() -> void:
    if not $Mute.button_pressed:
        $Sound.play()
func _mute(enabled: bool) -> void:
    if enabled:
        $Sound.stop()

Checks to run in the editor

  • Play produces sound only after user activation.
  • Mute stops playback and suppresses future Play until unchecked.
  • Equivalent visual cue remains available in assignment.

Native Godot 4.7.2.stable.official.ed1daf0bf headless compile and representative node-tree/runtime tests passed; see native-qa-results.json. Visual UI, audible output, exports and website submission still need separate checks.

Import a short original audio file — evidence task

  1. 1. Build the C-AUDIO lab with a short original sound.
  2. 2. Record filename, origin and duration in the asset inventory.

Deliverable. Audio lab source and asset inventory update.

Acceptance checks

  • VGC-L097-T1. Sound starts after pressing Play, not automatically at launch.
  • VGC-L097-T2. The imported file is included in the restored project.

Understanding question. Why include the actual sound file in the project artifact?

Include a downloadable project ZIP with project.godot, .tscn, .gd and original asset files when code changes. A private, teacher-accessible download link to that ZIP is equivalent. Screenshots or a playthrough do not replace editable source.

If this is still shaky. Use one short teacher-provided original sound or a privately recorded tap. Keep volume modest and retain text cues. Start with the first assigned task and re-run its acceptance test before adding the remaining feature.

Optional extra. Compare two sound choices with the same loudness and explain which better communicates the event. Document one changed parameter, your prediction, and the observed effect; optional, not required for completion.

Turn in typed notes and a JPEG, PNG, or WebP screenshot. One https address is stored as text and is not opened, extracted, or run. An MP3, WAV, M4A, MP4, or WebM file up to 4 MB can show a demo. The demo does not replace editable source. Zip and code files are refused. If there is no private link, keep the project on the family computer and review the code in person.

  • Your first 2D game

    Free public tutorial; no account; external asset download is optional, not used by this course.

    · Opening this link does not submit the lesson.
  • Exporting for the Web

    Free public documentation. Local editor play is the required alternative to web export.

    · Opening this link does not submit the lesson.

This is a preview. A parent assigns the lesson and chooses the due date after the student is enrolled. The answer key is not on this page.

Print this lesson