gamercade-io / gamercade_console

A Neo-Retro Fantasy Console. Make WASM-powered, networked multiplayer games.
https://gamercade.io
Apache License 2.0
169 stars 10 forks source link

Implement SFX & BGM Data API Functions: get_lengths #57

Closed RobDavenport closed 2 years ago

RobDavenport commented 2 years ago

Now that bgm_is_active and channel_is_active are removed, we need a way to notify the game logic how long a sound will last.

I propose adding two more functions to the data_api

  1. bgm_length_secs(index: i32) -> f32 which returns the length of the BGM in seconds.
  2. bgm_length_frames(index: i32) -> i32 which returns the length of the BGM in frames.
  3. sfx_length_secs(index: i32) -> f32 same as 1, but for SFX.
  4. sfx_length_frames(index: i32) -> i32 same as 2, but for SFX.

While we don't have looping BGM or SFX yet, I figure we could use INFINITY or NaN or a negative number to represent looping ones in the future.

For the "frame" based ones, this should be an integer for the sound to completely complete. For example, if a SFX would take 15.5 game frames to complete, it should return 16.

Task List: