Browser port of Hedgewars
Hi team,
I have recently tried to port Hedgewars to the browser using WebAssembly.
You can test it out right now at https://webwars.link — hotseat mode works out of the box (two teams, one keyboard, taking turns). Right-click to pick a weapon, Space to fire, Enter to jump, Arrow keys to move. First load pulls ~190MB of game assets, but after that it should be cached and loads should be near-instant (work in progress).
Multiplayer is live too, but also in 'work in progress' mode: try it at https://webwars.link/lobby.html, pick a nickname, create or join a room, and play against someone else.
On the technical side: the engine compiles to WASM through the Pascal → pas2c → C → Emscripten pipeline. I replaced the IPC (Inter Process Communication) protocol with a JavaScript message queue, changed the main loop to not block the only thread available in the browser, and added a sprite batch system to speed up the rendering. Multiplayer runs through the real Hedgewars server — a Node.js WebSocket gateway bridges browsers to the TCP protocol. Fair warning: multiplayer is still buggy, and rendering differs a bit from the original game in places. I'm actively working on fixing all of that. You can find more details on github.
Huge thanks to Wuzzy, nemo, unC0Rr, koda, sheepluva, alfadur and every developer who worked on the project. Thanks to the Hedgewars community for being great. Also, this project wouldn't exist without pas2c — thanks to unC0Rr for writing it. And of course to the team for building a solid game engine that actually survives transpilation to C and then to WASM.
FAQ:
- Does it work on mobile?
- No, I have no idea how to implement controls at the moment
- Why not a pull request to the original project?
- Never thought this would even work, by the time it did, a lot of code was changed, didn't want to break the main repo
- Why the game doesn't work in Safari?
- No idea, just found out about it after posting this message
The full source of this project is at https://github.com/apmlabs/webwars (GPL v2, same as Hedgewars).