Jul 31, 2022 - Why I gave up on Nim


For a number of years, I’ve been looking for a great new programming language to make games with. When I came across nim, it felt like a breath of fresh air and my search seemed to be over. However, after trying it for a month or so, I have sadly concluded that it’s not the right language for me.


Nim is a great language, in fact out of the languages that have come onto the scene in the last decade or so, nim is one of the more promising. This is not meant as a critique of the language overall, only that in its current state, and for my purposes, it is not the right choice.

Why look for a new language?

When it comes to making games, I’m a bit of an all-rounder these days, but I’m still a programmer by trade, and it’s what I’m best at. Writing code is what I do, and care most about, and the current state of game programming leaves a lot to be desired:

  • Good, established game frameworks often use old languages like C/C++, which lack modern features or aren’t as nice to work with
  • Python, arguably the most popular language and which is fun and productive, but cross platform deployment is still an afterthought, with no standard, battle-tested method
  • Modern JavaScript / TypeScript are also nice to work with, but is browser-first, and on desktop tends to be laggy and bloated
  • Unity, the 800-pound gorilla of game engines, uses C# which is a good language. But the experience of making games in Unity is very much about wrangling with an engine, rather than coding in C#.

This leaves a family of less-popular game frameworks for all sorts of languages, including libGDX for Java, XNA for C#, OpenFL for Haxe, Love2D for Lua and so on. Because their userbases are much smaller, they tend to be less polished and capable, but at least there’s usually one for your favourite language.

Thus the choice for me boils down to:

  • A good framework that uses an old language
  • A good engine that is highly opinionated and frustrating to work with
  • A good framework that is suboptimal
  • A suboptimal framework in a good language

As a programmer, I could deal with the last option the best, and this is where nim fits.

Nim for Games


Nim is a great language, at least on paper. It is compiled making it fast, but also borrows great features from languages such as Python, making it a nice language to work with too. It can even compile to a JavaScript backend, which means it supports the web as a first-class platform.

In practice it is a bit quirky and has a learning curve. It uses var, let and const, but in ways that are quite different from what you might expect if you came from say, JavaScript. Its documentation is reminiscent of early-2000s-era language docs, and representation on stackoverflow is sorely lacking. Its choice to take features from Ada/Modula, two very uncommon languages, seems arbitrary and will trip up most learners, for example in its case/of statements instead of the more well known switch/case. And its pass-by-value/pass-by-reference system is something I still haven’t gotten the hang of. But overall I still found it good, and most of these issues are nitpicks and quite understandable for a new language, and would probably be easy to overcome once one becomes familiar. I certainly found it faster to learn than golang, which is much more opinionated and arbitrary.

One key shortcoming is the lack of IDE support for debugging. For simple projects, you can get away with no debugging or just occasional print-statement debugging. Fantasy consoles don’t have debugging but they are still excellent for making small games. But for anything more complex, a good debugger can often overcome an otherwise bad coding experience. For example, even though memory bugs are common in C, I’ve been able to work around them with conditional break statements in my C games. And the ability to modify values at runtime with dynamic languages is such a powerful debugging tool. Sadly this isn’t available in nim. If nim were otherwise a pleasure to work with, this could be overlooked to a degree.

The big disappointment however is with the lack of a good game framework in nim. As of writing, the list of game frameworks and engines for nim is a modest collection of barely-actively-maintained wrappers around SDL. This is ok for my purposes since I’m interested in 2D game development, and SDL is mostly fine. The standout in this list is nico, a PICO-8 inspired engine, and this piqued my interest.

As previously mentioned, I’m a big fan of fantasy consoles. Their limitations also make them easy to pick up and learn, and limitations drive creativity. Nico not only couples a nice language with a great API, it is cross platform, including for the web, out of the box. Its feature list contains all the nice things that make fantasy consoles great.

Unfortunately it is not actively maintained, despite plenty of community interest. As of writing I still have several pull requests that have stayed open for months. Being far from mature, a lack of maintenance is a critical flaw. I want to make games, not engines, which means fixing the issues myself is out of the question. Given that I was still learning the ropes with nim, this is an extra headache I did not need.

What’s Next

For now I’ll be taking a short break in my quest to find the perfect games programming language. Plenty of options exist no matter your favourite language, although you’ll be putting up with some limitations. I’ve been looking into MoonScript + love2D lately. Coupling a cool language made by a game dev’s game dev, with a venerable 2D games framework, this makes a promising combo. A lot of features are missing however, so I’m not diving in head first. If I do ever jump into a new language, I’ll be sure to keep my experiences with nim in mind, now that I have a better idea of what makes or breaks a language for games programming.

Mar 23, 2022 - How may sprites do different perspectives need?


I love 2D sprite-based games; they are easy to read and a great way to showcase beautiful art and character designs. A major downside is that drawing each sprite is a significant amount of work, and it can grow exponentially depending on the game perspective!

Choosing the right game perspective has a big impact on your game’s art budget. Here’s a rundown of different 2D game perspectives and how many different sprites you need to budget for.


Perspective Sprites Needed Genres Examples
Top-down (vertical) 1x action, arcade, puzzle, vertical scrollers Galaxian Centipede GTA 2
Side view 1-1.5x beat-em-up, fighting, infinite runner, metroidvania, platformer, run-and-gun, side-scrolling Knytt Mighty Final Fight Flashback
Isometric (4 directions) 2-2.5x business simulation, turn based strategy, turn based tactics Super Mario RPG Theme Hospital Tactics Ogre
Oblique 3-3.5x action RPG, overhead shooter, RPG, RTS Seiken Densetsu 3 Z Zelda Four Swords
8-directional 5-5.5x 8-directional shooter, real time tactics Gauntlet 2 Super Contra Syndicate

Top-down: 1x

Games with a perfectly vertical perspective are the cheapest to create sprites for. You only need to create one set of sprites, and even if you need characters to face different directions, you can let your rendering software rotate the sprites. A lot of simple or retro game genres use this economical perspective - arcade games, top-down action games, puzzle games and so on.


The downside is that it’s not a very flattering perspective. Characters can’t show off their face, only the tops of their heads. Buildings only show their roofs, which are rarely shown in real life, plus it’s hard to show important parts like doors.

On the other hand, cars and other vehicles look perfectly fine in this perspective. This is why games like top-down vertically scrolling shooters use airplanes or spaceships instead of human characters.


Grand Theft Auto 1 and 2 used a top-down perspective for its human characters and cars. The cars look great; the human characters less so.

Side view: 1-1.5x

Side view games are also very cheap to draw for. Compared with top-down games, it shows off characters and scenery much better. Because of this ability to intimately show off characters, it’s popular in fighting games and metroidvanias.


Games like infinite runners only have one fixed view of the characters; even if you allow the characters to move left and right, as in platformers, side-scrollers or run-and-gun games, you can mirror the sprite, which is very cheap to do.

contra sprites

Contra sprites are simply mirrored, which makes the character’s handedness change. But it’s so fast-paced that most people don’t notice.

One caveat is if the characters are handed, it can look odd when they are simply mirrored. Sometimes you can get away with it; if not or if you care about it enough, it can take some time to rework to mirror the sprites.

dragon quest sprites

Dragon Quest, like many JRPGs, have the player look at the character sprites for long periods of time, so it pays off to make sure they are holding their swords and shields on the correct sides, no matter which way they are facing.

Isometric (4 directions): 2-2.5x

Isometric games combine the advantages of the freedom of movement of top-down games with the attractiveness of side-scrolling games. If you limit movement to the four diagonal directions, you can get away with only creating 4 sets of sprites: front-facing and back-facing, with the other two directions simply mirrored!

Super Mario RPG

In Super Mario RPG, although the main characters can be viewed in 8 directions, most characters are only shown in the 4 isometric directions.

Similar to the side-scrolling perspective, if your characters are handed, you may need to slightly rework sprites when they are mirrored.

Because not being able to move vertically or horizontally feels unnatural for action games, this perspective finds more use in slower-paced genres like turn based tactics and turn based strategy games.

Theme Hospital

In the business simulation game Theme Hospital, players build out rooms in their hospital while managing staff and incoming patients. The isometric view helps show off the rooms and quirky characters.

Oblique: 3-3.5x

3/4 oblique perspective is a highly versatile perspective. It can show off characters and scenery well, as well as feeling natural for players to move around in, so it can be used for a lot of genres. Overhead shooters, RPGs, RTS games, ARPGs, as well as genres that work with the other top-down-style perspectives… oblique perspective can handle them all.

Seiken Densetsu 3

The cost is that the sprite work required is substantial: you need at the very least 3 sets of sprites: side view (mirrored for left/right), front view and back view. Again, if your characters are handed, you may need to rework the side view sprites too. For this reason oblique view sprites tend to be simpler compared to side-scrolling games.

Super Contra

Super Contra has overhead shooting sections where the player can face many directions. Its iconic, set-piece bosses however are fixed in one perspective, so the artists can afford to put extra effort into them.

8-directional: 5-5.5x

If you want to draw characters moving in 8 directions, the amount of sprites required approaches the limit of what’s sensible for hand-drawn sprites. You must draw at least 5 sets of sprites: in addition to the 3 sets for the cardinal directions, you also need 2 sets for the diagonals.

Gauntlet 2

Gauntlet 2, a fast-paced shooting game, being able to move and shoot in 8 directions is crucial, so the sprites are drawn in all 8 directions.

The substantial artwork cost means you should carefully consider workarounds:

  1. Allow players to move diagonally, but only draw 4 directions
  1. Use the perfectly vertical top-down perspective, letting your renderer or image editor do the rotation for you

Alien Breed

  1. Use 3D-rendered sprites, which also lets you add arbitrary number of angles


This perspective only makes sense for games where showing the 8 directions is really important, like 8-directional shooters.

You can use either oblique or isometric perspectives for buildings; oblique may be easier to navigate but isometric shows off more sides for buildings.


Jan 22, 2022 - RPG Game Loops


Role playing games come in many different flavours but the game loop is a common element in all of them. Whether the game is combat oriented, or it focuses on stats and progression, exploration, or story telling, almost all RPGs follow this simple loop:

rpg loop

The terms and mechanics may differ between games but the loop is the same. The dungeon may not be a literal dungeon, but a forest, ruins or wilderness.

What’s interesting is how different RPGs use mechanics to compel players through this loop. Let’s look at a few classic mechanics:

Quests ❗️

Perhaps there wouldn’t be much of a game if there no reason to enter the dungeon where you can get killed. Most RPGs would have a main quest, the call to adventure that compels the player to venture forth.


But RPGs, especially Western ones, have lots of side quests, big and small, which give players a more immediate reason for fighting. They could be as mundane as killing 20 rats, or as involved as pulling off a heist.

the ultimate heist

In Oblivion, The Ultimate Heist is a 7-part quest that involves stealing a unique item from the most heavily guarded location in the game.

Quests are extremely flexible and are only limited by the quest designer’s imagination. They can direct the player to arbitrary places and perform arbitrary tasks, thereby showing parts of the game that the designer wants. In return, players want the quests to make sense in the game world, and reward them with game lore in addition to mechanical rewards. Players tend to look down on lazy, highly mechanical quests such as “kill X creatures” or “fetch some item”.

Once quests are complete, the prospect of returning to the quest giver to collect the reward can be an incentive to return to town, so quests can work in both directions in the game loop.

Energy 💚🏥

This is where dungeon fighting consumes a form of energy, which is replenished back in town. The most common is health or HP; fighting almost inevitably involves getting hurt, and the most effective way of getting healed is returning to town. A great example is in Final Fantasy: although alternate healing methods exist, resting at the town inn is always the cheapest option, by far. Pokemon takes this even further, with its free healing Pokemon-centers.

ff4 hp

Health is an unforgiving energy system because the penalties for losing it are harsh - your party dies and you lose the game! But it is not the only type of energy, and the penalties don’t need to be as harsh for it to work. Mana, or MP, is also common. For magic-focused characters, fighting without mana is much harder, which is a strong incentive for returning to town.

A side note on restoration items: they can alleviate the harshness of energy penalties, but usually they are expensive, so that they don’t completely overwhelm the energy system.

Encumbrance 🧳

Loot is a big part of many RPGs. Many older RPGs had limits on how many things a character could carry, due to technical constraints. But others set limits deliberately, so that characters could not loot items indefinitely, and must return to town to sell excess loot.

Diablo, more than any other RPG, focuses on inventory management and looting to drive its game loop. A typical dungeon run will have the player pick up mostly useless items, return to town to sell them off, and only occasionally do other things typically done in RPG towns - heal and recover, buy restoration items, upgrade equipment. This focus on looting was done to focus the game on the excitement of finding rare items.

loot loop

Other RPGs, like Fallout, The Elder Scrolls and various Dungeons and Dragons-themed CRPGs use weight limits, coupled with the fact that stronger characters can carry more items, for more flavour.

Compared to energy systems, encumbrance has the advantage of not harshly penalising the player, but still simulating the fatigue of adventuring that feels thematically apt. The obvious downside is that the encumbrance system needs to be designed just right - the game must not give the player too much or too few loot items - otherwise, in the case of too much loot, it can push players to return to town too often to avoid missing out on selling loot.

Crafting and Identification 🔨

Crafting is a game mechanic that has grown popular in RPGs over time. It adds flavour to the game world, but also acts as an additional force on the RPG game loop, by making loot more valuable if it is taken outside the dungeon.

Consider in The Witcher, where alchemical ingredients are usually harvested in the wilderness, but the player must return to a safe resting zone in order to make potions, oils or bombs.

craft loop

As a general rule, crafting ingredients are virtually useless on their own, but are also hard to gather unless the player travels to many different locations. This creates a weak, bi-directional pull in the game loop - players are encouraged to return to town to create useful crafting items, but also to travel to different locations to gather more ingredients.

Incidentally, item identification - with roots going all the way back to table-top RPGs - is somewhat similar to crafting, in the sense that unidentified items are useless, giving an incentive to return to town to identify them and make them useful.

Compared to energy systems and encumbrance, the influence of crafting on player behaviour is very weak, since crafting ingredients are usually very lightweight, meaning players are free to hoard them and not go back to town just to consume those ingredients. Many crafting systems are secondary in nature, so that players can often ignore crafting altogether.


After examining these different mechanics, all designed to keep players in a hamster-wheel-like loop of town-dungeon-town-dungeon, it may seem arbitrary and player-hostile. Indeed, many RPGs have added quality-of-life conveniences designed to shorten this loop, reduce its urgency, or in some cases to skip it altogether. These include things such as:

  • Fast travel / town portals
  • Torchlight’s pets who can return to town to sell loot and buy potions on your behalf
  • Item stashes, pack mules to carry more loot
  • Special items that replace town functions (full-healing items, identify scrolls)

So why do we even need this loop, why not keep the player in combat the whole time, and allow them to do everything there?

Delayed Gratification

A lot of the “pull”-type mechanics give the player something to look forward to, by delaying the immediate reward. Items that must be crafted elsewhere, rare items that need to be fixed or unlocked, completed quest rewards that need to be completed, these all act as mini-cliffhangers, something to keep the player in the game, or for them to look forward to once they return.


Games need a regular pacing in order to keep the player engaged, without being bored or fatigued.

[pacing in games fills] a very important role: it helps the player stay in “the flow”. … The clear [rhythm] it gives to the game helps [players] learn to anticipate challenges and get ready right on time. Providing relief in regular intervals prevents players from getting tired too quickly. Sudden surges of intensity supply them with adrenaline rushes, and the increasing wave structure makes sure they have time to recover afterwards.

Beyond Pacing: Games Aren’t Hollywood

Towns in RPGs are an effective way to serve as lulls in the action, so the player can mentally take a break, reflect, and prepare for the next surge in action.

Composite Game Design

RPGs can be seen as an example of a composite game, a combination of story-telling and turn-based combat. It is therefore important to have different sections that showcase one or the other.

Indeed, the grandfather of RPGs, Dungeons & Dragons had roots in wargames, and was created by adding role-playing elements like character creation and storytelling to wargames.


D&D’s combat was based off a medieval wargame. Wargames have a rich and long history, going back centuries as a tool to train officers. Some have kept this tradition by focusing on realism. Others streamlined the mechanics to make it more fun and interesting, for example by adding fantasy elements.

Just as in composite games where lessons learned from one genre can be used to solve problems in the other, RPGs often use story-telling elements to influence combat, and vice versa, to create a genre that is greater than the sum of its parts. Great RPGs often have superb examples of this inter-dependence of genres. New items, mechanics or characters are introduced via the story. Players in turn can often influence the story or game world by taking on different quests, representing different combat encounters, or sometimes even by performing combat in different ways. This way, players engage with the game on multiple levels.

FF4 Cecil

In Final Fantasy 4, the main character undergoes a permanent class change as part of a key story arc, tying his character’s moral redemption to a big change in gameplay.

The separation of town and dungeon segments becomes clear. It is hard to tell an engaging story while the player is focused on combat. RPGs therefore need a safe, slow-paced town segment to develop and engage with the story, such as taking on quests and tweaking their characters, and a dangerous, fast-paced dungeon segment to fully explore the combat impacts of their choices.