August 4th, 2024

Porting My JavaScript Game Engine to C for No Reason

Dominic Szablewski announced the high_impact game engine, a C port of his Impact JavaScript engine, designed for 2D action games, supporting multiple platforms and featuring essential game development tools.

Read original articleLink Icon
ExcitementNostalgiaAppreciation
Porting My JavaScript Game Engine to C for No Reason

Dominic Szablewski has announced the development of a new game engine called high_impact, which is a port of his original Impact JavaScript engine to C. This small engine is designed for 2D action games and is compatible with Windows, Mac, Linux, and WebAssembly. The project is inspired by the decline of Flash, which once dominated web gaming but was phased out due to lack of support on platforms like iOS. Szablewski's initial foray into game development led to the creation of Biolab Disaster, demonstrating that games could be made without Flash using the JavaScript Canvas2D API.

The high_impact engine aims to simplify game development by providing essential features such as tile-map loading, entity management, physics, and collision detection. It is structured as a framework rather than a library, allowing developers to implement their game logic within its scaffold. The engine supports two platforms, SDL and Sokol, and utilizes JSON for level formats to maintain compatibility with the original Impact engine.

High_impact also includes a straightforward entity system, collision detection methods, and rendering capabilities through OpenGL and a basic software renderer. Szablewski emphasizes the simplicity and depth of C, which he finds enjoyable to work with, and aims to create a minimalistic yet effective game development tool. The project is open-source and licensed under MIT, with the source code available on GitHub.

AI: What people are saying
The comments reflect a mix of appreciation and curiosity regarding the high_impact game engine and its implications for game development.
  • Many users express admiration for the performance and capabilities of games developed with the Impact engine, such as Cross Code.
  • There is a discussion about the transition from JavaScript to C, with some users noting performance improvements.
  • Several comments highlight the importance of open-source contributions and the potential for further development, including a port to WebAssembly.
  • Users share personal experiences with game development and the challenges of monetizing side projects.
  • Some comments touch on the historical context of game engines and the evolution of web technologies.
Link Icon 31 comments
By @namuol - 2 months
I owe a lot of the most informative programming work I’ve done to Impact.

Impact was so ahead of its time. Proud to say I was one of the 3000 license owners. One of the best purchases I’ve ever made. The only game I’ve ever really properly finished was made in Impact.

I loved that the source code was part of the license, and even modified the engine and the editor to suit my needs.

I was so inspired that I worked on my own JS game engine (instead of finishing games - ha!) for years after. I never released it, but I learned a ton in the process and made a lot of fun gamejam games with it.

I was also inspired by Impact’s native iOS support (Ejecta), but frustrated that it didn’t run on Android (at the time at least), so I fumbled my way through writing JVM bindings for V8 and implemented a subset of WebGL to run my game engine on Android without web views.[0] I made the repo for V8 bindings public and to my surprise it ended up being used in commercial software.

I won’t bore you with the startup I tried to bootstrap for selling access to private GitHub repos, which was inspired by Impact’s business model…

Anyway, it warms my heart and makes me laugh with glee to see Impact getting an update for the “modern” web with a C port!

I’d say these are strange times for the web, but I can’t remember a time when things were anything but strange. Cheers!

[0]: https://github.com/namuol/jv8

By @senkora - 2 months
> Many Web games were created with Impact [the game engine from the article] and it even served as the basis for some commercial cross-platform titles like Cross Code, Eliot Quest and my own Nintendo Wii-U game XType Plus.

Cross Code is an excellent game. I knew that it used web tech and I was constantly amazed by how performant it was on the Nintendo Switch hardware. I would guess that this engine deserves some credit there!

By @fitsumbelay - 2 months
"Thoughts on Flash" may just have saved the Web platform at its hour of greatest need, ie. creeping dominance of a single piece of software.

I believe that somewhere in there was frustration with Adobe who seemed to abandon the MacOS platform support for Windows' much larger user base, eg. Mac versions were always behind Windows versions. Perhaps Jobs also may've felt that there would be no Adobe without Apple as much as the other way around but that's speculative

The game looks slick af btw,

By @hammycheesy - 2 months
> My decision to sell it was met with a lot of backlash but was successful enough to launch me into a self-sustained career.

As someone who is interested in eventually freeing myself from the corporate job and diving head-first into my side projects, I would love to hear more about this aspect.

For some reason the idea of trying to charge folks for the work I would normally do for the fun of it on the side is daunting to me, even though I know it could enable me to focus on doing the stuff I love full-time.

By @kirbyfan64sos - 2 months
Had to log in to my rarely-used HN account to mention that I had played Biolab Disaster over and over again years back but lost track of it and forgot the name. Kinda wild to find it again by sheer luck!
By @o11c - 2 months
> high_impact is not a “library”, but rather a framework. It's an empty scaffold, that you can fill. You write your business logic inside the framework.

I normally phrase this in a much more negative way: a "framework" is simply a "library" that does not place nice with others. It's good to hear a sensible positive phrasing for once.

By @muragekibicho - 2 months
Somewhat related. Your QOI lossless file format coupled with 7Zip outperfoms lossless PNG. Amazing work!
By @nottorp - 2 months
> for No Reason

Out of respect for your player's battery life, perhaps :)

By @dgb23 - 2 months
I like the part about memory management. Arenas are so simple.

In the (toy) web server I'm writing I initially also started with arenas. However I quickly realized that I don't actually need to grow and shrink memory at all.

Currently I'm simply allocating the memory I need up front then slice it up into pieces for every module.

When we're programming, we often pretend like we could be needing arbitrary amounts of memory, but that's not necessarily the case.

Many things actually have very clear limits. For the rest one can often define them. And if you enumerate those, you know how much memory you will need.

It is fun to think about and define those limits up front. It builds a lot of confidence and promotes a healthy frugality.

By @cubano - 2 months
ohhh I love your use of UNION to create a polymorphic-type ENTITY data structure. Nice work and design.

I still love futzing around in C...It was the original langauge I learned and God did I struggle with it for years. Like the OP mentioned, C is awesome because its such a concise language but you can go as deep as you like with it.

Thanks for all your efforts and the writeup...the game has a throwback Commander Keen-type vibe to it and I loved that franchise for a minute back in Carmack's pre-3D days.

By @tomcam - 2 months
Fun idea, open source for maximum learning value, seemingly flawless execution, vanity-free and clear writeup—what a lovely contribution to the world. I feel privileged just seeing things like this.
By @Defletter - 2 months
As one of those 3000 licence holders, I'm happy to see a revival of Impact :) wonder how nicely it plays with Zig.
By @mgaunard - 2 months
The history section does not feel quite accurate.

From what I recall, what killed Flash wasn't iOS, but rather the acquisition of Macromedia by Adobe.

By @jonwinstanley - 2 months
Looks like it’s a great game engine. Why does the article state its near end of life?

Are there new engines that are far better?

By @andai - 2 months
I did 5 game jams this year, 4 of them in various WebAssembly languages (C++, Zig, Odin, Rust).

In the end I switched back to JS/TS, because I found way more benefit from minimizing layers of abstraction and translation (WS is set up so you are forced to interface with JS to actually do anything), more than the benefits of any language or library.

(An exception might be something like Unity, due to the excellent featureset, but the IDE has become so slow it's unbearable...)

By @two_handfuls - 2 months
Nice writeup! I didn’t see mention of the license: it’s MIT and the code is on GitHub.
By @slowhadoken - 2 months
I used to play X-Type all the time on iOS, it’s how I discovered Impact. I love web-based games but lately I’ve been tempted to write in C or C++. Did you notice dramatic gains in optimization porting Impact from JavaScript to C?
By @esschul - 2 months
Remember I was working on an impact.js game 10 years ago. Just can't seem to find the source code! First time I hired a guy to create some graphics. Very inspiring gaming platform.
By @hoten - 2 months
Amazing work!

FYI - in non-fullscreen mode, on my Mac / Chrome, the bottom of the viewport is cut off. So can only play in fullscreen.

By @jokoon - 2 months
What amazes me is how modern javascript engines are able to optimize for a "hot execution path".
By @pjmlp - 2 months
Love the honesty of the headline.

The game looks cool.

By @elfelf11 - 2 months
Would love to have a ruby binfing.
By @syockit - 2 months
> The name high_impact is a nod to a time when C was considered a high level language.

Weird, considering that JS is an even higher level language.

By @uberman - 2 months
Thanks, this was a great read.
By @zoogeny - 2 months
The next logical step is to port this to WASM so that it can run in the browser.
By @moffkalast - 2 months
With WASM it might actually run faster in the browser as well.
By @taf2 - 2 months
Now to compile with wasm so we can use it in a browser
By @theapache64 - 2 months
dude is an OG!
By @cookiengineer - 2 months
Honestly I would never ever execute any code from this guy. He is the inventor/founder behind the coinhive crypto mining network. [1]

This guy made billions illegally [2], and maintained the biggest ransomware crypto coin network for years, by offering the tools and SDKs to fund dozens of cyber war involved agencies across the planet. [3]

I have no idea how he got away with it, because his name keeps appearing in lots of crypto trading companies and trade registries. (Not gonna post them, but you can google his name to find this evidence)

He even organized a doxxing campaign against brian krebs at the time called "krebsistscheisse" via his pr0gramm platform [4] [5] [6], to somehow defend the idea that abusing user's computers for personal enrichment is a legit way of making money if you donate some low percentage to cancer research with it?!?

Sorry, but I would never trust this guy's code again. You should be careful, and audit any code he writes before you execute it.

[1] https://krebsonsecurity.com/2018/03/who-and-what-is-coinhive...

[2] 30% fee of monero/XMR went to coinhive: https://coinmarketcap.com/currencies/monero/

[2b] Schuerfstatistik on pr0gramm, where it all started: https://web.archive.org/web/20231005033135/https://pr0gramm....

[2c] Troyhunt analysis after he snatched away the coinhive TLD: https://web.archive.org/web/20240804081830/https://www.troyh...

[3] https://www.trendmicro.com/vinfo/us/security/news/cybercrime...

[3] https://krebsonsecurity.com/tag/dominic-szablewski/

[4] https://krebsonsecurity.com/2019/03/annual-protest-raises-25...

[5] (German) https://www.t-online.de/digital/aktuelles/id_83466874/tausen...

[6] https://www.heise.de/news/krebsistscheisse-Spendenwelle-an-K...

(Lots of other articles about it, and that dominic szlablewski was the guy behind coinhive, and the original owner of pr0gramm, while still doing development work for the company that owns the imageboard officially nowadays)

By @leeoniya - 2 months
now rewrite it back to JS with https://github.com/KilledByAPixel/LittleJS

j/k :D

By @38 - 2 months
> Except for SDL2, all libraries are bundled here (see the libs/ directory).

https://github.com/phoboslab/high_impact#libraries-used

yep. exactly why I dont use C anymore. the package management story is so bad/non existent, that the typical approach is to just vendor everything. no thanks.