Leaving the prototype phase

October 2024

Up until this point, koi farm 2 has been developed in Javascript using WebGPU. While koi farm 1 was also web based and ran fine on most desktop computer systems, the limits of browser based software are becoming a problem for koi farm 2, which has a much more complex game world.

  • Koi farm 2 has many more ponds than its predecessor. Not all ponds will be in view, and a lot of content will have to be simulated in the background. Javascript has come a long way, but it is inherently much slower than computer programs can be, which is effectively limiting the amount of content I can put in the game.
  • Web based applications can actually use multithreading, and koi farm 2 makes use of it for procedural content generation, but multithreading capabilities are very limited. Most importantly, both simulating the game and rendering happens on the same thread, and there's no way to escape this limitation. That means I can really only use a single CPU core for all important work, resulting in lag spikes and performance limitations. It also means the game won't hit the target frame rates on monitors with high refresh rates.
  • Javascript takes up a lot of memory, and Javascript with multithreading uses even more. Most computers have plenty of memory nowadays, but I'd rather use that for something fun. I've also noticed that many players are playing koi farm 1 while simultaneously using other software, and I think this should remain possible without issues.
  • While I love the WebGPU API, it doesn't allow me to access the GPU to its full extent. I can do most things I want to do, but I can't do them very efficiently and there are many modern features I can't use.
  • We want to bring this game to more platforms. While Javascript made it super easy to build koi farm 1 for Android and iOS, it won't run on any consoles. Since we're now licensed Nintendo developers, we definitely want to release on their consoles too.

That's why I've decided to port the Javascript codebase to C++. This addresses all performance and multithreading problems, and it allows me to use a low level graphics API which gives me access to modern GPU features. On top of that, we'll be able to build it natively on all platforms we want to target. It also removes the limitations that are now affecting game design choices, we were about to leave some features out just because of a lack of performance budget.

Luckily, I'm proficient at writing C++, so I was able to make a good start with porting the game this month. I've set up most of the basics, and pond digging is almost implemented. The most difficult part is porting the graphics engine to a more modern multithreaded system, but since WebGPU was designed to target modern hardware, the differences aren't too big.

A significant advantage of prototyping with Javascript is that getting stuff to render and creating interfaces is really easy, it's great for trying things out. I think it's been very useful to have all those Javascript prototypes, but I'll now have to move them into C++ to make sure the concepts hold up at scale.