For the second pull request I decided to look for another game project, one that was more mature than ShooterCarnival. This led me to stumble upon Threadbare, which was another collaborative open-source game, this time in a top down style. Since this game was further along, I hoped that I'd be able to implement something more advanced.
The first thing I looked at was a UI bug where the movement hint was misaligned and not at the bottom of the viewport. After taking the time to explore the Threadbare repository and structure, I found where the main scene was and got around to seeing how the objects were laid on the scene.
The fix turned out to be a really simple variable change, but it did take some time to get to know the project. Nonetheless, I wanted to do more than this.
I actually noticed a few things like missing audio while playtesting, so I looked for an issue like that to work on and found this.
Adding audio required creating AudioStreamPlayer nodes in each scene that linked to audio files (The 'click' noises were created in a separate issue but not implemented yet), and I had the menu working after a bit of trial and error but quickly realized how unwieldly it would be to have to make the same audio nodes in every scene. Therefore, I researched how to implement it globally and found that I could create an AudioManager file and link it globally in the project settings so that every scene could access the variables in it. This meant that I only needed to call a function for each button press.
AudioManager file:
@tool
extends Node
@onready var ui_click_sound: AudioStreamPlayer = %Click
@onready var ui_click_back_sound: AudioStreamPlayer = %ClickBack
@onready var ui_click_toggle_sound: AudioStreamPlayer = %ClickToggle
func play_ui_click():
ui_click_sound.play()
func play_ui_click_back():
ui_click_back_sound.play()
func play_ui_click_toggle():
ui_click_toggle_sound.play()
This is a way cleaner solution, and only needs to be called like this:
func _on_continue_button_pressed() -> void:
AudioManager.play_ui_click()
No imports or adding variables or anything. Neat.
After filing the pull request I found a couple interesting things about their workflow. First it rejected the formatting on the new .gd file I created by automatically running a linter and formatter, but it also failed a test because I was missing copyright text information at the top of the file.
It's required that the file has this at the start:
# SPDX-FileCopyrightText: The Threadbare Authors
# SPDX-License-Identifier: MPL-2.0
Which I found is copyright header information using the Software Package Data Exchange format. Threadbare uses the REUSE specification which specifies that all files in a repository are labelled with their license in a machine readable way.
After fixing those minor things (I just installed and ran gdformat on my own), I later noticed there was Github Action workflow that created a playable version of the game, which is great. You can play it here to see the audio in action in the main menu.
I didn't fully close the issue with this pr (adding audio to -every- button instance), but I think I provided the means of doing so. I mostly want to make sure the maintainers are happy with this approach before hunting down every menu in the game. All in all this release has made me more comfortable with contributing to Godot engine games, and I'm finding it really enjoyable as a way to learn how to use the engine. My biggest barrier to starting my own projects is my lack of knowledge, so if I tried to start a project in Godot from scratch I would just keep getting in my own way. Right now I'm getting some great experience implementing things in different types of games, and I plan to contribute to a Godot addon as well, if not try to contribute to Godot itself again.
Top comments (0)