Kontra.js Postmortem

Steven Lambert
js13kGames
Published in
5 min readOct 9, 2019

Every year at the end of the Js13kGames competition, participants are encouraged to write a postmortem about their experience making a small game in one month. This year I too was encouraged to write a postmortem. But not about making a game, but about Kontra.js and my experience writing and maintaining a Js13kGames game library.

Where it All Began

Back in 2015, after a few years of learning how to create JS games, I decided I was tired of copying the same code into every new game. The year before I had entered my first game for Js13kGames and noticed that there weren’t any game libraries that would fit in such a small file size limit. So I had an idea; why not put all the code I keeping copying into a single library and make it small enough to use in Js13kGames.

Gru from Despicable Me in a giant hole saying “Light bulb”

And thus, Kontra.js was born.

Maintaining a Tiny Game Library

For the first few years after it was created, the library was mostly just a pet project that I used in my own games and wasn’t really used by anyone else. To help me keep working on it, I decided that every year before JS13kGames started, I would try to work on the library and improve it in some way. As a result, I was able to reduce the file size almost every year. Some years, that was the only thing I was able to do to the library.

Starting in 2018 (three years after it was created) the library began to really be used by others. The year before saw the first game made with Kontra.js outside of my own games. Combined with an article I wrote earlier that year on making a game with Kontra.js, I think others saw potential in the library and were willing to give it a go.

During the 2018 Js13kGames competition, users opened up about 15 issues and 10 PRs, with about half of them coming from a single user! On top of that, I was also working on my own game for that year and so had to balance fixing issues and finishing my game. In the end, I resolved the issues but my game wasn’t quite finished.

In Preparation For This Years Competition

In the months leading up to the competition, I once again worked to reduced the file size of the library by converting it to use ES6 modules. This also allowed users to pull in just the parts of the library they needed instead of all of it. It took a few months, but the result was well worth it.

I also continued to work on resolving issues that trickled in from users who were starting to use the library outside of Js13kGames, including a game for Ludum Dare 44, and its first use in a commercial game.

Player entering a phone number on a rotary phone in a minigame for the Trivia Murder Party 2 Jackbox game

How This Years Competition Went

This year was an exciting time for Kontra.js as it saw the most activity since its inception. For the competition there were:

  • 20 opened issues
  • 17 opened PRs
  • 7 new contributors
  • 6 releases
  • 30 games made using Kontra.js

The 30 games are:

A lot of PRs and issues this year were focused on improving the Tile Engine code and making Sprites work better with it. It was exciting to see that part of the library get more use and become more robust. We were also able to add a few new features such as the ability to flip a Sprites image using negative width/height.

I’ve been blow away by the growing community. Even now, after the competition has ended, there’s still activity and users helping to make the library better. They’ve been able to resolve bugs, add multi-touch support, improve performance, support different keyboard layouts, and even started to help with the next version of the library!

Moreover, the community has been actively helping to answer questions from other users and contribute to discussions on PRs and issues! There has been so much activity that I even had to start using Github tags just to help keep things organized.

Where to Go From Here

With so much activity this year, I decided to put together a Twitter poll to get input from the community about what would make the library more useful. The result was that the library should be even smaller. There were quite a few entries this year that took the library as a base and then removed everything they didn’t need.

Trying to squeeze every byte of savings out of the library was a common thing I heard. So for next year, I plan to make the library even more modular so you only get exactly what you need. Things like splitting the monolithic Sprite class into smaller pieces, adding a composition layer so you can add optional features like rotation and anchor, and moving collision detection out of the Sprite should all help make it the smallest it can be.

There were also lots of requests to keep expanding the library with new features. Things like adding scene, view, and sprite management, gesture support, and UI components. Thanks to ES6 modules, I can continue to provide new features that can be brought into a game only when needed.

I look forward to see where the library goes for next years competition, and for all the future games that will be made with it. Thank you for letting me be part of your amazing games and for helping to make the library even better.

--

--

Steven Lambert
js13kGames

Web developer, HTML5 game developer, JavaScript enthusiast. Creator of the kontra.js game mirco-library https://github.com/straker/kontra