Hacking Slash was born in 24 hours at HackMerced — their very first hackathon. I built a dungeon crawler in Pygame where you pick a hero, fight through waves of enemies, and try to survive. It worked great on desktop, but I wanted people to play it in the browser without installing anything. This is the story of that port.

Why Not Just Use Pygbag?

Pygbag compiles Pygame to WebAssembly and runs it in the browser. I actually tried this first, and it works — but the load time is significant, the canvas rendering has quirks on mobile, and debugging becomes much harder when your Python is running through Emscripten.

Phaser, on the other hand, is a JavaScript game framework built for the browser from the ground up. It handles sprites, physics, input, and audio natively. The tradeoff: I had to rewrite the game logic in JavaScript.

What Translated Cleanly

The game design itself ported well. Tile-based dungeon layouts, enemy spawn patterns, and the ability system all mapped to Phaser concepts without much friction:

  • Pygame sprite groups became Phaser groups
  • Collision detection moved from manual rect checks to Phaser's arcade physics
  • The game loop structure (update/draw) is basically the same in both frameworks

What Didn't

Input handling was the biggest surprise. Pygame gives you raw keyboard events; Phaser has its own input system that works differently on desktop vs mobile. I had to add touch controls from scratch — virtual joystick and action buttons — which didn't exist in the original game at all.

Asset loading was another adjustment. Pygame loads images synchronously; Phaser uses an async preloader. This meant restructuring the initialization flow so scenes don't start until their assets are ready.

Mobile Touch Controls

Adding mobile support was probably the most work per feature. The virtual joystick needs to feel responsive without covering important UI, and the hit areas for action buttons need to be generous enough for thumbs. I went through several iterations before landing on the current layout.

Was It Worth It?

Absolutely. The game loads fast, runs on any device with a browser, and I can deploy updates by pushing to git. The Phaser version is the one people actually play, because there's no install barrier.

If you want to try it: play Hacking Slash. And for more lessons from building these games, check out 5 Things I Learned Making Games Solo. For a broader look at all three approaches to getting a Pygame game into the browser, see How to Get Your Pygame Game Running in a Browser.