Try Splat
Run
var canvas = document.getElementById("canvas"); var manifest = { "images": {}, "sounds": {}, "fonts": {}, "animations": {} }; var game = new Splat.Game(canvas, manifest); game.scenes.add("title", new Splat.Scene(canvas, function() { // initialize the scene this.player = new Splat.Entity(100, 100, 30, 30); this.player.draw = function(context) { context.fillStyle = "#ff0000"; context.fillRect(this.x, this.y, this.width, this.height); }; this.floor = new Splat.Entity(0, 220, canvas.width, 20); this.floor.draw = function(context) { context.fillStyle = "#0000ff"; context.fillRect(this.x, this.y, this.width, this.height); }; }, function(elapsedMillis) { // update the simulation / call .move() on everything this.player.vx *= 0.9; // friction this.player.vy += 0.01; // gravity if (game.keyboard.isPressed("left")) { this.player.vx = -0.3; } if (game.keyboard.isPressed("right")) { this.player.vx = 0.3; } this.player.move(elapsedMillis); if (this.player.collides(this.floor)) { this.player.resolveCollisionWith(this.floor); if (game.keyboard.isPressed("up")) { this.player.vy = -0.3; } } }, function(context) { // draw the frame / call .draw() on everything context.fillStyle = "#000000"; context.fillRect(0, 0, canvas.width, canvas.height); this.floor.draw(context); this.player.draw(context); })); game.scenes.switchTo("loading");