No pitfall, it is Beta-4!
What's new in the game?
No more swearing
The bad*ss scimitar has been renamed to awesome scimitar. Thanks to a fellow smasher, Super Tilt Bro us now appropriate for more people.
The Pit, completely re-done
The former version was more of a technical test than an actually enjoyable stage. It was particularly ugly, hard to navigate in and could be abused to pull off infinite combos.
The new version, is not only nicer to the eye but also fun to play! True to the original idea of “having a hole in the middle,” it removes the things that did not work well to replace it by moving platforms. Moving platforms are common for a good reason: it is super cool to play with.
Sick of the five seconds music loop that serves as main theme? Good news, the sound engine has been greatly improved so we can now have full-length tracks. There is now a music for the menus, one in-game and the game-over music is greatly improved. Thanks to the new sound engine, it is a choice to use a cute little loop for gameover instead of a long music. Shortening this track allows getting immediately to the point, not wasting time listening music when all you have to do is starting another game.
What's new under the hood?
New music engine
Basically, a music is a sequence of notes. The original music engine of Super Tilt Bro was storing musics just like that, as a sequence of notes. It leads to an incredibly large amount of data needed to store a single tracks. There is approximately fifteen notes per second, so a two minutes music is around 1800 notes. The engine uses three bytes per note, leading to more than 5 kilo-bytes per track. In a standard NES cartridge, it is 30% of the available space. If you store three tracks like that, you may not have enough space to put a music engine to play it.
The music engine has not been rewritten from scratch, but it now uses a cool property shared by most musics: chorus and verses. A music is a sequence of verses separated by a unique chorus. So half of the music is the sequence of notes that makes the chorus. The music engine plays a sequence of samples, which are each a sequence of notes. Samples may contain one verse, the chorus or just a part of a verse. It allows reusing data for repeated sequences pretty well, so space is less a problem than before.
To go further, it would be possible to do a better encoding of the notes. Music engines from other games use a format using approximately one byte per note. They are also more complex and, for now, the space needed to store three tracks is manageable. It will be the next step to the perfect music engine.
In Super Tilt Bro, a stage is defined as a list of platforms, each one having coordinates, and a set of functions that execute when the engine needs it. Typically, the stage's initialization function draws the screen's background, then the engine uses platforms positions to know if characters are falling or not.
The way to implement moving platforms is quite obvious: when a platform needs to move, update the platform's position in stage's data. Current stage data is copied in RAM when starting the game, so everything seems good, we can modify it at will. There is still two little problems.
First, we need somewhere to write the code that moves platforms. The engine itself does not have to take care of this, this is specific to a stage. So we add a callback function to stages, to be called each frame, so stages can do whatever they want. Existing stages, simply register a function that does nothing while our new stage sets a function handling moving platforms.
The second problem is to actually draw the moving platform. In the typical case, the screen is drawn once, when loading the stage, then the engine put sprites on top of it for characters and special effects. We can update the screen's background between frames, but there graphics are aligned on a 8x8 pixels grid. We do not want a platform that jumps 8 pixels at a time, we aim at smooth movements. To place a platform with one pixel precision, we can use sprites.
Summarily, each frame a function of the stage is called. This function moves platforms in stage's data and displays it as sprites.
Sprite-efficient particles usage
The NES allows for 64 sprites of 8x8 pixels at the same time on screen. Super Tilt Bro associates each one to a particular use:
0-15: player 1 sprites 16-31: player 2 sprites 32-35: unused 36-42: particle block 0 43-49: particle block 1 50-56: particle block 2 57-63: particle block 3
This is all fine, except that there is only 4 unused sprites. The Pit needs 8 sprites for its moving platforms. Almost half of the reserved sprites are for the particles' system, this had to be changed.
The particles' system is used for two things: showing the impact of a blow and popping explosions on death. It works by affecting particles emitters to a block, each time the game wants to display particles, an emitter is created and it uses sprites of its block for the effect. As, there is two possible emitters per character, it is convenient to have four blocks. One for impacts on player one, another for player one's death and the two sames for player two.
We can save two blocks as, for a given character, it is highly unlikely to need impact and death particles at the same time. Death generally occurs after an impact and impact particles are very short-lived. So the same result can be achieved while reserving only one particle block per player. Just take care to stop any active particle emitter when we recycle a block that is still active. The new sprites map is now:
0-15: player 1 sprites 16-31: player 2 sprites 32-49: reserved for stage's usage 50-56: particle block 0 57-63: particle block 1
Super Tilt Bro's Python library
Super Tilt Bro begins to have a lot of its own internal formats: animations, stages, music to name a few. It was funny to manipulate it in binary at the beginning, but as the projects grows in scope it becomes merely manageable. Some separate tools where developed to save time, but without consistency nor publishing it was pretty niche for some very specific workflows.
The former tools are now merged in a Python library, the stblib. The stblib is distributed with Super Tilt Bro's source code, it allows easy manipulation of its data structures and exporting it as json. So instead of writing a new stage in binary, one can do it in json (which is way more human-friendly) then write a tool that generates the binary. The long term goal will be to have a full editor allowing anybody to mod the game as easily as possible.
Get Super Tilt Bro. for NES
Leave a comment
Log in with itch.io to leave a comment.