Kevin's Research Blog

Usagi: The New 2D Game Engine on the Block

I learned about Usagi yesterday, and immediately got fascinated in it. As I was mindlessly scrolling through my Google News feed on my titular smart brick, a post from Games from Scratch appeared. The thumbnail featured what appeared like a pixelated version of Link from Breath of the Wild, with a similar tunic. Perhaps it's the Zeldaish fan art that drew me, but I clicked, and I was pleasantly surprised. While this game engine has nothing to do with Pascal, or even Python, or any other programming language I'm fond about, I loved it's sheer simplicity.

Some Game Engines are Over-engineered

This is more of a personal opinion, but a lot of game engines tend to include so much in their APIs. They tend to include almost any feature you could ever think of wanting your game to have. This can both be a blessing, and a curse.

Usagi itself is written in Rust, and it embeds in the Lua programming language to code your actual game. This has led to the game engine itself only being 7.8MB! The rest of the data on top of that for an exported game, is your game assets and code. The game engine can create native executable for Linux, macOS, and of course Windows. Furthermore, it can also export to the wonderful world wide intertubes, where anyone can play it in their facy web exploring program of their choosing. This can enable a simple game demo to have a fairly far reach, and of course it could probably be sold on a marketplace. Which brings me to the licensing, it's FREE, not like in GPL, MIT, BSD, or even Apache. It is under an (un)license, which puts it entirely in the public domain! Like, if you love and know Rust for example, this could be a really amazing starting point for an extended game engine of your own. You can completely change the entire game engine to add new features specific to the game you are creating for example. As it is scriptable in Lua, you can further extend the Lua language to add additional functions which your game code can run for a custom game engine experience. It does use some 3rd party libraries, such as raylib, so as long you abide by the third party licenses that this program uses, or even replace them too I guess...

The Simplicity of Usagi

This engine doesn't come with a swath of features, and it's default resolution is at 320x180, the resolution can be changed through a configuration variable. Although, it is recommended to use the default resolution, and perhaps use a shader to enhance it's overall appearance when in full-screen. Although personally, at the default resolution full-screen at 1080p, it looks great. The graphics look very sharp and crisp, and really gives it a lot of retro vibes.

The default palette is that from the PICO-8, a slightly similar game engine, as Usagi was inspired by the PICO-8. It has some slight compatibility with it as well. However, it can easily swap in a completely different palette. Although one complaint, is that the sprites which you can take from a sprite sheet, does not downscale to the palette. When sprites are used, they use the exact colours within the sprites.png file. It is best to commit to a palette early on, so that anything manually drawn with the game engine's API uses the same colours as the sprites. Although, it is fully possible to create a game with a very mixed palette. With say, the sprites being full colour, but then all the UI elements use the more limited palette.

Some of the neat features I do find interesting, which I'd otherwise need to program myself, or interface into libraries for are:

Some Plans with ObjectPascal

So, Usagi is missing a lot of features that I need to implement myself, although it is said that some third party programs like Tiled have a Lua export option. I may try this editor out one day, but I am thinking of actually building my own map editor in ObjectPascal, which will actually export into a pure binary file. This will allow the maps to be loaded and rendered quicker. It will also allow my games to incorporate some additional unique features right into my own map editor. For example, one thing common to video game maps are events, where the player steps into the specific tile, and something happens. I'll be adding a miniature scripting system, which will go along with the maps themselves. This will allow some basic actions to be easily stored within the map data itself, rather than being hardcoded into the game's Lua code. As keeping track of positions on a map, and then writing a bunch of if-then statements is incredibly tedious to manage. This miniature scripting system will allow basic actions, such as showing dialogues of text, for character interactions and story driven moments, along with the ability to change to another map. These and more will be actions which will be set within my map editor, and saved alongside the map data itself, which then Usagi can draw, and run these event scripts as needed.

Depending if any of these applications seem helpful for other people developing games with Usagi, I may also consider open sourcing them. If I do open source them, they will also include the needed Lua Module so the custom data formats the programs produce can be easily used.

#current #hobbyist #opinions #usagi