Java Applets
Flash apps
Silverlight apps
Unity Web Player
HTML5
<= require plugin
<= require plugin
<= require plugin
<= require plugin
<= no plugins, just browser!
Chapter 1
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
ctx.fillStyle = "green";
ctx.fillRect(10, 10, 100, 100);
ctx.moveTo(0,0);
ctx.lineTo(200,100);
ctx.stroke();var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
ctx.fillStyle = "green";
var x = 10;
var y = 10;
function paint() {
ctx.fillRect(x, y, 100, 100);
}
function update() {
x += 2;
y += 2;
}
function step() {
update();
paint();
window.requestAnimationFrame(step);
}
step();function toggleFullScreen() {
if (!document.fullscreenElement) {
document.documentElement.requestFullscreen();
} else {
if (document.exitFullscreen) {
document.exitFullscreen();
}
}
}canvas.requestPointerLock()
if(document.pointerLockElement === canvas) {
console.log('The pointer lock status is now locked');
} else {
console.log('The pointer lock status is now unlocked');
}
document.exitPointerLock();
document.addEventListener('pointerlockchange', lockChangeAlert, false)Chapter 2
Pure Vanilla is fine, but takes time
Pixi.js (2D API for WebGL)
Rigid body dynamics, collision detection, soft body dynamics, fluid dynamics, etc.
JS is sloooow!
Games need performance!
Web Assembly is on the way
= native browser sandbox to run bytecode