2.2 Basic concepts of HTML5 game development
History of JavaScript games
1998 Donkey Kong by Scott Porter ran in a browser, was written with HTML, JavaScript and CSS. The game library was called "Game Lib". He also created a sprite with more than 150 different positions to emulate a rotation.
In the early 2000s DHTML games, creation of "Game Lib 2" game library. Peter Nederlof's Beehive game lib, created Rotatrix.
From 2005 Ajax - multiplayer games. Also emulators of old computers, running games like Freeciv.
Useful html elements and APIs for games
canvas
element
can have multiple
canvas
elements on a page even stack on top of each other like transparent layers.the requestanimationframe
API
targets 60 frames/s
the <video>
element for animated textures (and other uses)
it can controlled from javascript
the <audio>
element and the web audio API
has an API to play streamed audio. For sound effects the the Web Audio API is much better. It's 100% javascript api designed for working real time with uncompressed sound for generating procedural music.
the
gamepad API
already implemented by some browsers
websockets
websockets and webRTC for real-time communication between clients