Porting my JavaScript game engine to C for no reason

  • 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

  • > 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!

  • "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,

  • > 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.

  • 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!

  • > 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.

  • Somewhat related. Your QOI lossless file format coupled with 7Zip outperfoms lossless PNG. Amazing work!

  • > for No Reason

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

  • 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.

  • 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.

  • 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.

  • As one of those 3000 licence holders, I'm happy to see a revival of Impact :) wonder how nicely it plays with Zig.

  • 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.

  • 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?

  • 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...)

  • Nice writeup! I didn’t see mention of the license: it’s MIT and the code is on GitHub.

  • 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?

  • 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.

  • 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.

  • What amazes me is how modern javascript engines are able to optimize for a "hot execution path".

  • Love the honesty of the headline.

    The game looks cool.

  • Would love to have a ruby binfing.

  • > 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.

  • Thanks, this was a great read.

  • The next logical step is to port this to WASM so that it can run in the browser.

  • With WASM it might actually run faster in the browser as well.

  • Now to compile with wasm so we can use it in a browser

  • dude is an OG!

  • 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)

  • now rewrite it back to JS with https://github.com/KilledByAPixel/LittleJS

    j/k :D

  • > 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.