3 ms·
I have taken a similar approach for the few modest games and fun tools I've developed. Twenty years ago, I would have likely turned to C or Perl, carefully wei
by susam 1y ago
I have taken a similar approach for the few modest games and fun tools I've developed. Twenty years ago, I would have likely turned to C or Perl, carefully weighing their pros and cons for maximum portability. But these days I just whip up an HTML page with some CSS and JavaScript. My tools are not performance intensive, so this approach has served me well. Perhaps, one day, I'll use WASM for similar projects when performance becomes a concern.
I have found HTML5 Canvas and JavaScript to be very effective for writing small games. If sound is needed, there is Web Audio available too, right within the web browser. It is quite possible to write simple games without using any external JS libraries by sticking to first principles only: drawing simple shapes with fillRect(), implementing simple collision detection algorithms, generating simple tones using OscillatorNode, etc. Here is one such game I wrote sometime back: <https://susam.net/invaders.html https://susam.net/invaders.html>.
Also, by embedding all CSS and JavaScript into a single HTML file, the game/tool becomes instantly portable. All we need to do is host the HTML file somewhere, or send the file to someone, in order to share the game. Even when it is hosted on a website, savvy users can curl/wget it, or simply perform "Save Page As" to download it and run it as a local app!
Further, if the HTML is written and formatted neatly (rather than being bundled or minified), the endangered subspecies of developers who still like to "View Source" can easily copy, edit, and customise the code to suit their own needs, and see their changes take effect instantly.