Godoku v0.3.7


Update

This week, we're bringing a couple of small touches of polish.

  1. Modal menus that pop up over other controls now display a darkened background so it's easier to tell when a modal has control.
  2. We finally figured out how to fix the `Next Song` button, which you can map in `Settings`!
  3. Improved dpad and keyboard inputs when a LineEdit control is focused. Your gamepad will no longer get stuck when you try to enter text!
  4. Additional translations for older alerts that were using string literals.
  5. Various GUI updates, including smoothing menu transitions and making modal pop up/down more responsive.

Godot Dev

This update has been significantly less of a pain than some of the more recent devlogs. The signal architecture has been paying off in rearranging and reconnecting various nodes without having to rewrite code.

The hardest one was the `Next Song` feature. It uses the Godot AudioStreamRandomizer resource type to automatically randomize selecting an audio file from an array of files. That's not hard to write on your own, but it's usually a good idea to pick off-the-shelf parts for better support.

The problem with it was that the audio player checks to see if a request to play a new stream is for the currently playing stream. Since the resource file that contains references to all of the BGM is always the same, it was technically always playing the same resource and would never try randomizing again.

You'd think you could just stop and start it to circumvent that, but due to factors like fadeout times and deferred calls, it never finished a stream before the new play request came in. We solved it by simply padding out the call with enough time to clear it. These aren't mathematically derived times (that's how the feature got stuck never working!), but instead we just tested a variety of values until it worked consistently.

Once we found the solution, it was satisfyingly simple to put together with timers and signals.

if event.is_action_pressed("next_song"):
         SoundManager.stop_music(MUSIC_FADEOUT_TIME)
         get_tree().create_timer(MUSIC_NEXT_SONG_TIME).timeout.connect(
             func():
                     self.play_music()
         )

Overall, it's been a fun week to work in Godot!

Files

Godoku_0.3.7.zip 47 MB
27 days ago

Get Godoku

Leave a comment

Log in with itch.io to leave a comment.