7 ms·
While writing games in any programming language is a very rewarding experience, I have found HTML5 Canvas and JavaScript to be very effective for writing games
by susam 3y ago
While writing games in any programming language is a very rewarding experience, I have found HTML5 Canvas and JavaScript to be very effective for writing games as absolute beginners too. If sound is needed, there is Web Audio too, all available 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, e.g., drawing simple shapes with fillRect(), 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, if the entire game is written as a single HTML file, the game becomes immediately distributable too. All one needs to do is host the HTML file somewhere or send the file to someone in order to share the game.
- klabb3 3y agoSeconded! Especially if you only have keyboard controls. Once you have mouse events there is no mapping between mouse position and an object in game, which makes it a bit harder. If so, you may wanna use svg. It makes it easy to handle mouse events, rendering is “free” and you can also do smooth animations with CSS. The main downside imo is that svg has more browser inconsistencies for some reason. Example: https://loz.payload.app/ https://loz.payload.app/
- deleted 3y ago[deleted]
- marcosdumay 3y agoThe web is becoming a really good OS. We just need make web assembly better for higher level languages, because neither javascript not rust are an end-all great language for small games.