SSVOpenHexagon icon indicating copy to clipboard operation
SSVOpenHexagon copied to clipboard

Make a Timeline that is controlled specifically by a level's music

Open Morxemplum opened this issue 3 years ago • 0 comments

I've been brainstorming on how to do this for the past few hours. And I'm raising this as an issue so that I can remind myself to do it when I got the time to do so (which won't be for a bit).

I've noticed that one Steam Review, in particular, mentions the game's lack of rhythm, and how it degrades the quality of the game. To be fair, I see where he's coming from. Super Hexagon incorporates a sense of rhythm by syncing the beat pulse/zoom to the music itself. When you look at other arcade games that could attract the same audience to Open Hexagon, they all have a sense of rhythm to them (a lot of them being classified as rhythm games). Open Hexagon isn't necessarily a rhythm game when we take a look at the default packs, because that's not the intended purpose of the default packs. However, there can be some additional elements of rhythm incorporated into the default levels by having levels mimic Super Hexagon's mechanic. But most importantly, pack developers can create levels that can make Open Hexagon fit the definition of a rhythm game.

However, when it comes to thinking of a solution, Super Hexagon's rhythm mechanics are only an edge case. I've also been noticing that a lot of Open Hexagon pack developers are incorporating rhythm into their levels, most notably by using timed events on the event timeline. However, using the event timeline to incorporate rhythm has restrictions:

  • Music files can only have one starting position, as a completely different starting position can invalidate an entire sequence of events completely.
  • They do not take into account that music can loop. Sure, you could definitely shove all of the events into a function and call it every time the song loops, but that means the durations are going to be relative instead of absolute, and that can be more tedious to calculate.
  • Music-related events can be mixed up with actual events if the pack developer doesn't properly organize their code, which can lead to a bloated and unorganized event timeline.

We have been making many measures for Open Hexagon pack developers to help their level incorporate rhythm and sync to their music, but I believe this is a feature that helps change Open Hexagon for those who want to add rhythm more than any changes we've made so far. This will make their job significantly easier, and can possibly be paradigm-shifting in terms of what levels can be on the Workshop.

The Music Timeline

I thought the best way to incorporate rhythm into a level is for there to be a completely new timeline, apart from the pattern timeline and the event timeline we know and love. I'm calling this timeline the music timeline, for self-explanatory reasons. Here are some unique features that this Music Timeline will have.

  • Like the pattern and event timelines, it can evaluate blocks of Lua code
  • The "cursor" will be on where the music is currently playing. The cursor for the event timeline, for reference, is based on the time elapsed for an attempt. However, where the song is playing, the cursor will be there. So if a song starts 70 seconds in when a level starts, the cursor will be at 70 seconds instead of 0.
  • This will be an absolute timeline. The pattern and event timelines are relative timelines, as they are based on when the level starts. However, music must be absolute. Since the starting position of a song can be randomized, we cannot rely on a relative timeline because it will take too many calculations to adjust for new starting positions.
    • Since this is an absolute timeline, waiting functions are not needed. If we want relativity, we would use Lua arithmetic to apply relative transformations to an absolute value.
  • Unlike the other timelines, this timeline will not remove events after using them. So when a song loops, a string of events can be re-executed to ensure consistency. Or, if you decide to rewind or change the timestamp of the music, it will replay the events alongside the music.

The Lua implementation

First, we need to establish which prefix the music timeline functions will be using. Since this is audio-related, a_ is the best choice here. Now, what functions will be added?

  • a_evalTo(float mSeconds, string mLua): Similar to t_eval and e_eval, this function will add a Lua block of code onto the music timeline at mSeconds. Since the music timeline is absolute, it needs an additional argument to specify where in the timeline it must be placed.
  • a_clear(): Clears all events on the music timeline.

Seriously, that's it. Again, the waiting functions are not needed since we're working with an absolute timeline. Perhaps later down the road, we can add functions relating to getting all of the code blocks that will be executed at a specific timestamp. But that is for another time.

I'm looking forward to implementing this, as this will definitely be a game-changer for not only pack developers but the players as well, as it can improve their experience towards the game. Again, I can't start on this for some time because I'm occupied, but when I can start working on the source code, I'll be glad to work on this feature. :)

Morxemplum avatar Apr 09 '21 01:04 Morxemplum