From a472189cb625bdde26d725a7d301e6fbf08a6c6d Mon Sep 17 00:00:00 2001
From: Ali Shakiba <ali@shakiba.me>
Date: Sun, 13 Mar 2016 00:26:13 -0500
Subject: [PATCH] update examples

---
 example/p2js-asteroids/app.js     | 435 ----------------------------
 example/p2js-asteroids/index.html |  25 --
 example/p2js-breakout/app.js      | 593 --------------------------------------
 example/p2js-breakout/bg.png      | Bin 4762 -> 0 bytes
 example/p2js-breakout/index.html  |  23 --
 example/p2js-breakout/main.png    | Bin 49517 -> 0 bytes
 example/p2js-breakout/texture.js  |  49 ----
 7 files changed, 1125 deletions(-)
 delete mode 100644 example/p2js-asteroids/app.js
 delete mode 100644 example/p2js-asteroids/index.html
 delete mode 100644 example/p2js-breakout/app.js
 delete mode 100644 example/p2js-breakout/bg.png
 delete mode 100644 example/p2js-breakout/index.html
 delete mode 100644 example/p2js-breakout/main.png
 delete mode 100644 example/p2js-breakout/texture.js

diff --git a/example/p2js-asteroids/app.js b/example/p2js-asteroids/app.js
deleted file mode 100644
index 07383cb..0000000
--- a/example/p2js-asteroids/app.js
+++ /dev/null
@@ -1,435 +0,0 @@
-Stage(function(stage) {
-
-  var Math = Stage.Math;
-  
-  var SHIP = Math.pow(2, 1);
-  var BULLET = Math.pow(2, 2);
-  var ASTEROID = Math.pow(2, 3);
-
-  var spaceWidth = 16;
-  var spaceHeight = 9;
-
-  var shipSize = 0.30;
-  var shipReloadTime = 0.1;
-  var shipTurnSpeed = 4;
-
-  var bulletLifeTime = 2;
-
-  var asteroidRadius = 0.9;
-  var asteroidSpeed = 2;
-  var asteroidLevels = 4;
-
-  var allowShipCollision = true;
-  var hideShip = false;
-
-  var world;
-
-  var asteroidBodies = [];
-
-  var bulletShape;
-  var bulletBodies = [];
-
-  var shipBody;
-
-  var level, lives, lastShootTime = 0, gameover;
-
-  var key = {}, keyName = {
-    32 : 'shoot',
-    37 : 'left',
-    38 : 'up',
-    39 : 'right',
-    40 : 'down'
-  };
-
-  document.onkeydown = function(evt) {
-    gameover && start();
-    key[keyName[evt.keyCode]] = true;
-  };
-
-  document.onkeyup = function(evt) {
-    key[keyName[evt.keyCode]] = false;
-  };
-
-  function init() {
-    // Init p2.js
-    world = new p2.World({
-      gravity : [ 0, 0 ],
-    });
-
-    // Create bullet shape
-    bulletShape = new p2.Particle();
-    bulletShape.collisionGroup = BULLET;
-    bulletShape.collisionMask = ASTEROID;
-
-    // Add ship physics
-
-    var path = [ [ -0.15, -0.15 ], [ 0, -0.1 ], [ 0.15, -0.15 ], [ 0, 0.2 ] ];
-
-    shipBody = new p2.Body({
-      mass : 1,
-      position : [ 0, 0 ],
-      angularVelocity : 1
-    }).noDamping();
-
-    shipBody.fromPolygon(path);
-    shipBody.shapes[0].collisionGroup = SHIP;
-    shipBody.shapes[0].collisionMask = ASTEROID;
-
-    // Catch impacts in the world
-    // Todo: check if several bullets hit the same asteroid in the same time
-    // step
-    world.on('impact', function(evt) {
-      var bodyA = evt.bodyA, bodyB = evt.bodyB;
-
-      if ((bodyA.id == shipBody.id || bodyB.id == shipBody.id)) {
-        // Ship collided with something
-        if (!hideShip && allowShipCollision) {
-          var aship = bodyA.shapes[0].collisionGroup == SHIP;
-          var ship = aship ? bodyA : bodyB;
-          var asteroid = !aship ? bodyA : bodyB;
-
-          crash(ship, asteroid);
-        }
-
-      } else if (bodyA.shapes[0].collisionGroup == BULLET
-          || bodyB.shapes[0].collisionGroup == BULLET) {
-        // Bullet collided with something
-        var abullet = bodyA.shapes[0].collisionGroup == BULLET;
-        var bullet = abullet ? bodyA : bodyB;
-        var asteroid = !abullet ? bodyA : bodyB;
-
-        if (asteroid.shapes[0].collisionGroup == ASTEROID) {
-          hit(asteroid, bullet);
-        }
-      }
-    });
-  }
-
-  function start() {
-    gameover = false;
-    level = 1;
-    lives = 3;
-    uiStatus();
-    play(true);
-    addAsteroids();
-    uiStart();
-  }
-
-  function end() {
-    gameover = true;
-    uiEnd();
-  }
-
-  function play(position) {
-    if (shipBody.world) {
-      shipBody.world.removeBody(shipBody);
-    }
-
-    if (position) {
-      shipBody.position[0] = shipBody.position[1] = 0;
-    }
-    shipBody.force[0] = shipBody.force[1] = 0;
-    shipBody.velocity[0] = shipBody.velocity[1] = 0;
-    shipBody.angularVelocity = shipBody.angle = 0;
-    world.addBody(shipBody);
-    hideShip = false;
-    allowShipCollision = false;
-    setTimeout(function() {
-      allowShipCollision = true;
-    }, 2000);
-  }
-
-  function tick() {
-    // Set velocities
-    shipBody.angularVelocity = 0;
-    if (key.left) {
-      shipBody.angularVelocity += shipTurnSpeed;
-    }
-    if (key.right) {
-      shipBody.angularVelocity -= shipTurnSpeed;
-    }
-
-    // Thrust: add some force in the ship direction
-    if (key.up) {
-      var magnitude = 2, angle = shipBody.angle + Math.PI / 2;
-      shipBody.force[0] += magnitude * Math.cos(angle);
-      shipBody.force[1] += magnitude * Math.sin(angle);
-    }
-
-    // Shoot
-    if (key.shoot && !hideShip && world.time > lastShootTime + shipReloadTime) {
-
-      // Create a bullet body
-      var bulletBody = new p2.Body({
-        mass : 0.05,
-        position : shipBody.position
-      }).noDamping();
-      bulletBody.addShape(bulletShape);
-      bulletBodies.push(bulletBody);
-      var magnitude = 2, angle = shipBody.angle + Math.PI / 2;
-
-      // Give it initial velocity in the ship direction
-      bulletBody.velocity[0] += magnitude * Math.cos(angle)
-          + shipBody.velocity[0];
-      bulletBody.velocity[1] += magnitude * Math.sin(angle)
-          + shipBody.velocity[1];
-      bulletBody.position[0] = shipSize * Math.cos(angle)
-          + shipBody.position[0];
-      bulletBody.position[1] = shipSize * Math.sin(angle)
-          + shipBody.position[1];
-
-      world.addBody(bulletBody);
-
-      // Keep track of the last time we shot
-      lastShootTime = world.time;
-
-      // Remember when we should delete this bullet
-      bulletBody.dieTime = world.time + bulletLifeTime;
-    }
-
-    for (var i = 0; i !== bulletBodies.length; i++) {
-      var bulletBody = bulletBodies[i];
-
-      // If the bullet is old, delete it
-      if (bulletBody.dieTime <= world.time) {
-        bulletBodies.splice(i, 1);
-        world.removeBody(bulletBody);
-        i--;
-        continue;
-      }
-      wrap(bulletBody);
-    }
-
-    for (var i = 0; i !== asteroidBodies.length; i++) {
-      var asteroidBody = asteroidBodies[i];
-      wrap(asteroidBody);
-    }
-
-    wrap(shipBody);
-  }
-
-  // Adds some asteroids to the scene.
-  function addAsteroids() {
-    while (asteroidBodies.length) {
-      var asteroidBody = asteroidBodies.shift();
-      world.removeBody(asteroidBody);
-      // asteroidBody.uiRemove();
-    }
-
-    for (var i = 0; i < level; i++) {
-      var x = rand(spaceWidth);
-      var y = rand(spaceHeight);
-      var vx = rand(asteroidSpeed);
-      var vy = rand(asteroidSpeed);
-      var va = rand(asteroidSpeed);
-
-      // Aviod the ship!
-      if (Math.abs(x - shipBody.position[0]) < asteroidRadius * 2) {
-        if (y - shipBody.position[1] > 0) {
-          y += asteroidRadius * 2;
-        } else {
-          y -= asteroidRadius * 2;
-        }
-      }
-
-      // Create asteroid body
-      var asteroidBody = makeAsteroidBody(x, y, vx, vy, va, 0);
-      asteroidBodies.push(asteroidBody);
-      asteroidBody.level = 1;
-      world.addBody(asteroidBody);
-    }
-  }
-
-  function asteroidLevelRadius(level) {
-    return asteroidRadius * (asteroidLevels - level) / asteroidLevels;
-  }
-
-  function makeAsteroidBody(x, y, vx, vy, va, level) {
-    var asteroidBody = new p2.Body({
-      mass : 10,
-      position : [ x, y ],
-      velocity : [ vx, vy ],
-      angularVelocity : va
-    }).noDamping();
-
-    var radius = asteroidLevelRadius(level);
-
-    var path = [];
-    var n = 8;
-    for (var i = 0; i < n; i++) {
-      var a = i * 2 * Math.PI / n;
-      var x = radius * (Math.sin(a) + rand(0.3));
-      var y = radius * (Math.cos(a) + rand(0.3));
-      path.push([ x, y ]);
-    }
-
-    asteroidBody.fromPolygon(path);
-
-    for (var i = 0; i < asteroidBody.shapes.length; i++) {
-      asteroidBody.shapes[i].collisionGroup = ASTEROID;
-      asteroidBody.shapes[i].collisionMask = BULLET | SHIP;
-    }
-
-    return asteroidBody;
-  }
-
-  function crash(ship, asteroid) {
-
-    if (asteroid.shapes[0].collisionGroup == ASTEROID) {
-      lives--;
-      uiStatus();
-
-      // Remove the ship body for a while
-      world.removeBody(shipBody);
-      hideShip = true;
-
-      if (lives <= 0) {
-        end();
-        return;
-      }
-      setTimeout(function() {
-        // Add ship again
-        play();
-      }, 1000);
-    }
-  }
-
-  function hit(asteroidBody, bulletBody) {
-    var aidx = asteroidBodies.indexOf(asteroidBody);
-    var bidx = bulletBodies.indexOf(bulletBody);
-    if (aidx != -1 && bidx != -1) {
-
-      // Remove asteroid
-      world.removeBody(asteroidBody);
-      asteroidBodies.splice(aidx, 1);
-      // asteroidBody.uiRemove();
-
-      // Remove bullet
-      world.removeBody(bulletBody);
-      bulletBodies.splice(bidx, 1);
-      // bulletBody.uiRemove();
-
-      // Add new sub-asteroids
-      split(asteroidBody);
-    }
-
-    if (asteroidBodies.length == 0) {
-      level++;
-      uiStatus();
-      addAsteroids();
-    }
-  }
-
-  function split(parent) {
-    if (parent.level < 4) {
-      var x = parent.position[0], y = parent.position[1];
-      var angleDisturb = Math.PI / 2 * Math.random();
-      for (var i = 0; i < 4; i++) {
-        var angle = Math.PI / 2 * i + angleDisturb;
-        var r = asteroidLevelRadius(0) - asteroidLevelRadius(parent.level);
-        var sx = x + r * Math.cos(angle);
-        var sy = y + r * Math.sin(angle);
-        var vx = rand(asteroidSpeed);
-        var vy = rand(asteroidSpeed);
-        var va = rand(asteroidSpeed);
-
-        var child = makeAsteroidBody(sx, sy, vx, vy, va, parent.level);
-        child.level = parent.level + 1;
-        child.angle = rand() * Math.PI;
-        world.addBody(child);
-        asteroidBodies.push(child);
-      }
-    }
-  }
-
-  // If the body is out of space bounds, wrap it to the other side
-  function wrap(body) {
-    var p = body.position;
-    p[0] = Math.rotate(p[0], -spaceWidth / 2, spaceWidth / 2);
-    p[1] = Math.rotate(p[1], -spaceHeight / 2, spaceHeight / 2);
-  }
-
-  // Returns a random number between -0.5 and 0.5
-  function rand(value) {
-    return (Math.random() - 0.5) * (value || 1);
-  }
-
-  p2.Body.prototype.noDamping = function() {
-    this.damping = this.angularDamping = 0;
-    return this;
-  };
-
-  var ui = {};
-
-  stage.on('viewport', function(size) {
-    ui.meta.pin({
-      scaleMode : 'in-pad',
-      scaleWidth : size.width,
-      scaleHeight : size.height
-    });
-    ui.p2.pin({
-      scaleMode : 'in-pad',
-      scaleWidth : size.width,
-      scaleHeight : size.height
-    });
-  });
-
-  init();
-
-  ui.p2 = new Stage.P2(world, {
-    lineColor : '#fff',
-    fillColor : ''
-  }).pin({
-    handle : -0.5,
-    width : spaceWidth,
-    height : spaceHeight
-  }).appendTo(stage);
-
-  stage.tick(tick);
-
-  ui.meta = Stage.create().pin({
-    width : 1000,
-    height : 1000
-  }).appendTo(stage);
-
-  ui.status = Stage.string('text').pin({
-    align : 0,
-    offset : 20
-  }).appendTo(ui.meta);
-
-  ui.gameover = Stage.string('text').value('Game Over!').pin({
-    align : 0.5,
-    scale : 1.6
-  }).appendTo(ui.meta);
-
-  function uiStart() {
-    ui.gameover.hide();
-  }
-
-  function uiEnd() {
-    ui.gameover.show();
-  }
-
-  function uiStatus() {
-    ui.status.value('Level: ' + level + ' Lives: ' + lives);
-  }
-
-  start();
-});
-
-Stage({
-  textures : {
-    text : function(d) {
-      d += '';
-      return Stage.canvas(function(ctx) {
-        var ratio = 2;
-        this.size(16, 24, ratio);
-        ctx.scale(ratio, ratio);
-        ctx.font = 'bold 24px monospace';
-        ctx.fillStyle = '#ddd';
-        ctx.textBaseline = 'top';
-        ctx.fillText(d, 0, 1);
-      });
-    }
-  }
-});
\ No newline at end of file
diff --git a/example/p2js-asteroids/index.html b/example/p2js-asteroids/index.html
deleted file mode 100644
index 0aa27a3..0000000
--- a/example/p2js-asteroids/index.html
+++ /dev/null
@@ -1,25 +0,0 @@
-<!DOCTYPE html>
-<html><head>
-  <title>Asteroids - Stage.js/P2.js</title>
-  <meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, width=device-width, height=device-height" />
-
-  <link href="../example.css" rel="stylesheet" />
-
-  <style>
-  body{ font-family: 'Courier New', Courier, monospace; background: #000; }
-  </style>
-
-</head><body class="dark">
-  <div class="about">A <a href="https://github.com/schteppe/p2.js">P2.JS</a> &amp; <a href="http://piqnt.com/stage.js/">Stage.js</a> Example
-   - <a href="https://github.com/piqnt/stage.js/tree/master/example/p2js-asteroids">Source</a></div>
-  <div class="hint">Use arrow keys &amp; space</div>
-
-  <script src="../example.js"></script>
-  <script src="../../dist/stage.web.js"></script>
-
-  <script src="../dep/p2.js"></script>
-  <script src="../../ext/stage-p2.js"></script>
-
-  <script src="app.js"></script>
-
-</body></html>
diff --git a/example/p2js-breakout/app.js b/example/p2js-breakout/app.js
deleted file mode 100644
index 254171b..0000000
--- a/example/p2js-breakout/app.js
+++ /dev/null
@@ -1,593 +0,0 @@
-var P2DEBUG = false;
-
-function Physics(ui, width, height) {
-
-  var world = this.world = new p2.World({
-    // broadphase : new p2.SAPBroadphase(),
-    gravity : [ 0, 0 ],
-    defaultFriction : 0
-  });
-
-  world.solver.stiffness = Number.MAX_VALUE;
-
-  var ballMater = new p2.Material();
-  var wallMater = brickMater = paddleMater = new p2.Material();
-
-  world.addContactMaterial(new p2.ContactMaterial(ballMater, wallMater, {
-    restitution : 1.0,
-  }));
-
-  var vwallShape = new p2.Line(25, 1);
-  vwallShape.material = wallMater;
-
-  var hwallShape = new p2.Line(18, 1);
-  hwallShape.material = wallMater;
-
-  var ballShape = new p2.Circle(0.5);
-  ballShape.material = ballMater;
-
-  var normalBrickShape = new p2.Rectangle(1.9, 1.9);
-  normalBrickShape.material = brickMater;
-
-  var smallBrickShape = new p2.Rectangle(0.9, 0.9);
-  smallBrickShape.material = brickMater;
-
-  var dropShape = new p2.Circle(0.3);
-
-  var fullPaddleShape = new p2.Convex([ [ 1.8, -0.1 ], [ 1.8, 0.1 ],
-      [ 1.2, 0.4 ], [ 0.4, 0.6 ], [ -0.4, 0.6 ], [ -1.2, 0.4 ], [ -1.8, 0.1 ],
-      [ -1.8, -0.1 ] ]);
-  fullPaddleShape.material = paddleMater;
-
-  var miniPaddleShape = new p2.Convex([ [ 1.2, -0.1 ], [ 1.2, 0.1 ],
-      [ 0.9, 0.4 ], [ 0.2, 0.6 ], [ -0.2, 0.6 ], [ -0.9, 0.4 ], [ -1.2, 0.1 ],
-      [ -1.2, -0.1 ] ]);
-  miniPaddleShape.material = paddleMater;
-
-  var BALL = 1, WALL = 2, BRICK = 4, DROP = 8;
-
-  vwallShape.collisionGroup = WALL;
-  hwallShape.collisionGroup = WALL;
-  fullPaddleShape.collisionGroup = WALL;
-  miniPaddleShape.collisionGroup = WALL;
-  normalBrickShape.collisionGroup = BRICK;
-  smallBrickShape.collisionGroup = BRICK;
-  ballShape.collisionGroup = BALL;
-  dropShape.collisionGroup = DROP;
-
-  vwallShape.collisionMask = BALL;
-  hwallShape.collisionMask = BALL | DROP;
-  normalBrickShape.collisionMask = BALL;
-  smallBrickShape.collisionMask = BALL;
-  fullPaddleShape.collisionMask = BALL | DROP;
-  miniPaddleShape.collisionMask = BALL | DROP;
-  ballShape.collisionMask = WALL | BRICK;
-  dropShape.collisionMask = WALL;
-
-  var leftWall = new p2.Body({
-    position : [ +9, -0.5 ],
-    angle : Math.PI / 2,
-    mass : 0,
-  });
-  leftWall.addShape(vwallShape);
-  leftWall.ui = null;
-  world.addBody(leftWall);
-
-  var rightWall = new p2.Body({
-    position : [ -9, -0.5 ],
-    angle : Math.PI / 2,
-    mass : 0
-  });
-  rightWall.addShape(vwallShape);
-  rightWall.ui = null;
-  world.addBody(rightWall);
-
-  var topWall = new p2.Body({
-    position : [ 0, +12 ],
-    mass : 0
-  });
-  topWall.addShape(hwallShape);
-  topWall.ui = null;
-  world.addBody(topWall);
-
-  var bottomWall = new p2.Body({
-    position : [ 0, -13 ],
-    mass : 0
-  });
-  bottomWall.addShape(hwallShape);
-  bottomWall.isBottom = true;
-  bottomWall.ui = null;
-  world.addBody(bottomWall);
-
-  var fullPaddle = new p2.Body({
-    position : [ 0, -10.5 ],
-    mass : 0
-  });
-  fullPaddle.paddleWidth = 3;
-  fullPaddle.addShape(fullPaddleShape);
-  fullPaddle.isPaddle = true;
-  fullPaddle.motionState = p2.Body.STATIC;
-  ui.fullPaddle(fullPaddle);
-
-  var miniPaddle = new p2.Body({
-    position : [ 0, -10.5 ],
-    mass : 0
-  });
-  miniPaddle.paddleWidth = 2;
-  miniPaddle.addShape(miniPaddleShape);
-  miniPaddle.isPaddle = true;
-  miniPaddle.motionState = p2.Body.STATIC;
-  ui.miniPaddle(miniPaddle);
-
-  var paddle = fullPaddle;
-  world.addBody(paddle);
-
-  function setPaddle(neo) {
-    if (paddle !== neo) {
-      world.removeBody(paddle);
-      neo.position[0] = paddle.position[0];
-      neo.velocity[0] = paddle.velocity[0];
-      world.addBody(paddle = neo);
-    }
-  }
-
-  function makeBall(pos) {
-    var body = new p2.Body({
-      mass : 1
-    });
-    if (pos) {
-      body.position = pos;
-    }
-    body.damping = 0;
-    body.angularDamping = 0;
-    body.addShape(ballShape);
-    body.isBall = true;
-    ui.newBall(body);
-    world.addBody(body);
-    return body;
-  }
-
-  function makeBrick(name, shape, pos) {
-    var body = new p2.Body({
-      mass : 0
-    });
-    if (pos) {
-      body.position = pos;
-    }
-    body.addShape(shape);
-    body.isBrick = true;
-    body.motionState = p2.Body.STATIC;
-    ui.newBrick(body, name);
-    world.addBody(body);
-    return body;
-  }
-
-  function makeDrop(name) {
-    var body = new p2.Body({
-      mass : 1
-    });
-    body.addShape(dropShape);
-    body.isDrop = true;
-    ui.newDrop(body, name);
-    world.addBody(body);
-    return body;
-  }
-
-  world.on('impact', function(evt) {
-    var a = evt.bodyA, b = evt.bodyB;
-    var ball = a.isBall && a || b.isBall && b;
-    var brick = a.isBrick && a || b.isBrick && b;
-    var bottom = a.isBottom && a || b.isBottom && b;
-    var paddle = a.isPaddle && a || b.isPaddle && b;
-    var drop = a.isDrop && a || b.isDrop && b;
-
-    if (drop) {
-      world.removeBody(drop);
-      if (paddle) {
-        ui.catchDrop(drop);
-      }
-    }
-
-    if (ball) {
-      var speed = ui.ballSpeed();
-      var velocity = ball.velocity;
-
-      if (velocity[1] >= 0) {
-        velocity[1] = Math.max(velocity[1], speed / 3);
-      } else {
-        velocity[1] = Math.min(velocity[1], -speed / 3);
-      }
-      var fix = speed
-          / Math.sqrt(velocity[0] * velocity[0] + velocity[1] * velocity[1]);
-      velocity[0] *= fix, velocity[1] *= fix;
-
-      ball.angularVelocity = ball.angle = 0;
-
-      if (brick) {
-        world.removeBody(brick);
-        ui.hitBrick(brick);
-
-      } else if (bottom) {
-        world.removeBody(ball);
-        ui.hitBottom(bottom);
-
-      } else if (paddle) {
-        ui.hitPaddle(paddle);
-      }
-    }
-  });
-
-  function findBrick() {
-    for (var i = 0; i < world.bodies.length; i++) {
-      if (world.bodies[i].isBrick) {
-        return world.bodies[i];
-      }
-    }
-  }
-  this.findBrick = findBrick;
-
-  function findBall() {
-    for (var i = 0; i < world.bodies.length; i++) {
-      if (world.bodies[i].isBall) {
-        return world.bodies[i];
-      }
-    }
-  }
-  this.findBall = findBall;
-
-  this.initGame = function() {
-    for (var i = world.bodies.length - 1; i >= 0; i--) {
-      var body = world.bodies[i];
-      if (body.isBrick || body.isBall || body.isDrop) {
-        world.removeBody(body);
-      }
-    }
-    setPaddle(fullPaddle);
-    makeBall([ 0, -5 ]);
-  };
-
-  this.startGame = function() {
-    var ball = findBall();
-    var a = Math.PI * Math.random() * 0.4 - 0.2;
-    var speed = ui.ballSpeed();
-    ball.velocity = [ speed * Math.sin(a), speed * Math.cos(a) ];
-  };
-
-  this.gameOver = function() {
-    for (var i = world.bodies.length - 1; i >= 0; i--) {
-      var body = world.bodies[i];
-      if (body.isBall) {
-        world.removeBody(body);
-      }
-    }
-  };
-
-  this.addRow = function(row) {
-    var over = false;
-    for (var i = 0; i < world.bodies.length; i++) {
-      var body = world.bodies[i];
-      if (body.isBrick) {
-        body.position[1] -= 2;
-        over = over || body.position[1] < -10;
-      }
-    }
-
-    for (var i = 0; i < row.length; i++) {
-      var cell = row[i], x = (i - 3) * 2, y = 9;
-
-      if (cell.type == 'none') {
-
-      } else if (cell.type == 'small') {
-        makeBrick(cell.color + 's', smallBrickShape, [ x + 0.5, y + 0.5 ]);
-        makeBrick(cell.color + 's', smallBrickShape, [ x - 0.5, y + 0.5 ]);
-        makeBrick(cell.color + 's', smallBrickShape, [ x + 0.5, y - 0.5 ]);
-        makeBrick(cell.color + 's', smallBrickShape, [ x - 0.5, y - 0.5 ]);
-
-      } else if (cell.type == 'normal') {
-        makeBrick(cell.color, normalBrickShape, [ x, y ]);
-      }
-    }
-
-    if (over) {
-      ui.gameOver();
-    }
-  };
-
-  this.dropDown = function(brick, name) {
-    var body = makeDrop(name);
-    body.position[0] = brick.position[0];
-    body.position[1] = brick.position[1];
-    body.velocity[1] = ui.dropSpeed();
-  };
-
-  this.addBall = function() {
-    var oldball = findBall();
-    var newball = makeBall();
-    newball.position[0] = oldball.position[0];
-    newball.position[1] = oldball.position[1];
-    newball.velocity[0] = -oldball.velocity[0];
-    newball.velocity[1] = -oldball.velocity[1];
-  };
-
-  var paddleTo = 0;
-
-  this.movePaddle = function(x) {
-    paddleTo = x;
-  };
-
-  this.miniPaddle = function() {
-    setPaddle(miniPaddle);
-  };
-
-  this.fullPaddle = function() {
-    setPaddle(fullPaddle);
-  };
-
-  this.tick = function(t) {
-    var balls = 0;
-    for (var i = world.bodies.length - 1; i >= 0; i--) {
-      var body = world.bodies[i];
-      // remove ball if passed through walls
-      if (Math.abs(body.position[0]) > width / 2
-          || Math.abs(body.position[1]) > height / 2) {
-        world.removeBody(body);
-      } else if (body.isBall) {
-        balls++;
-      }
-    }
-    if (balls < 1) {
-      ui.gameOver();
-    }
-
-    if (paddleTo !== paddle.position[0]) {
-      var padx = paddle.position[0];
-      var wallLimit = 9 - paddle.paddleWidth / 2;
-      var speedLimit = ui.paddleSpeed() * t / 1000;
-      if (paddleTo > padx) {
-        paddle.position[0] = Math.min(paddleTo, padx + speedLimit, wallLimit);
-      } else if (paddleTo < padx) {
-        paddle.position[0] = Math.max(paddleTo, padx - speedLimit, -wallLimit);
-      }
-    }
-  };
-
-}
-
-Stage(function(stage) {
-
-  var Mouse = Stage.Mouse;
-  var STORE_KEY = 'breakout-v1';
-
-  var width = 20, height = 26;
-
-  var state = {
-    score : 0,
-    combo : 1,
-    max : 0,
-    ready : false,
-    playing : false
-  };
-
-  stage.MAX_ELAPSE = 100;
-
-  stage.viewbox(width * 16, height * 1.12 * 16).pin('offsetY',
-      -height * 0.04 * 16).pin('align', -0.5);
-
-  var pscale = 16;
-
-  var physics = new Physics({
-    newBall : function(body) {
-      body.ui = Stage.image('ball', 10).pin({
-        'handle' : 0.5,
-        'scale' : 1 / pscale
-      });
-    },
-    newDrop : function(body, name) {
-      body.ui = Stage.image(name).pin({
-        'handle' : 0.5,
-        'scale' : 1 / pscale
-      });
-      body.ui.dropName = name;
-    },
-    newBrick : function(body, name) {
-      body.ui = Stage.image('b' + name).pin({
-        'handle' : 0.5,
-        'scale' : 1 / pscale
-      });
-      body.ui.drop = function() {
-        this.tween(70).alpha(0).remove();
-      };
-    },
-    hitBrick : function(brick) {
-      !physics.findBrick() && addRow();
-      state.score += state.combo;
-      // state.combo++;
-      updateScore();
-      dropDown(brick);
-    },
-    hitPaddle : function() {
-      // state.combo = 1;
-    },
-    hitBottom : function() {
-      !physics.findBall() && gameOver();
-    },
-    catchDrop : function(drop) {
-      var name = drop.ui.dropName;
-      if (name == '+') {
-        physics.addBall();
-
-      } else if (name == '-') {
-        Timeout.set(function() {
-          physics.miniPaddle();
-        }, 1);
-        Timeout.set(function() {
-          physics.fullPaddle();
-        }, 7500, 'mini');
-      }
-    },
-    miniPaddle : function(body) {
-      body.ui = Stage.image('paddleMini').pin({
-        'handle' : 0.5,
-        'scale' : 1 / pscale
-      });
-    },
-    fullPaddle : function(body) {
-      body.ui = Stage.image('paddleFull').pin({
-        'handle' : 0.5,
-        'scale' : 1 / pscale
-      });
-    },
-    gameOver : function() {
-      gameOver();
-    },
-    paddleSpeed : function() {
-      return 20;
-    },
-    dropSpeed : function() {
-      return -6;
-    },
-    ballSpeed : function() {
-      return (13 + state.score * 0.05);
-    }
-  }, width, height);
-
-  var board = Stage.image('board').appendTo(stage).pin('handle', 0.5).attr(
-      'spy', true);
-
-  var p2view = new Stage.P2(physics.world, {
-    lineWidth : 1 / pscale,
-    lineColor : '#888',
-    ratio : 4 * pscale,
-    debug : P2DEBUG
-  }).attr('spy', true).pin({
-    'align' : 0.5,
-    'scale' : pscale
-  }).appendTo(board);
-
-  p2view.on([ Mouse.START, Mouse.MOVE ], function(point) {
-    physics.movePaddle(point.x);
-  });
-
-  var maxscore = Stage.string('d_').appendTo(board).pin({
-    alignX : 1,
-    alignY : 1,
-    offsetX : -1.5 * 16,
-    offsetY : -0.5 * 16
-  });
-
-  var myscore = Stage.string('d_').appendTo(board).pin({
-    alignX : 0,
-    alignY : 1,
-    offsetX : 1.5 * 16,
-    offsetY : -0.5 * 16
-  });
-
-  var restart = Stage.image('restart').appendTo(board).pin({
-    align : 0.5,
-  });
-
-  stage.on(Mouse.CLICK, function() {
-    if (!state.playing) {
-      startGame();
-    }
-  });
-
-  stage.tick(function(t) {
-    if (state.playing) {
-      physics.tick(t);
-    }
-  });
-
-  try {
-    state.max = localStorage.getItem(STORE_KEY) || 0;
-  } catch (e) {
-  }
-
-  initGame();
-
-  function initGame() {
-    if (!state.ready) {
-      p2view.tween(100).pin('alpha', 1);
-      restart.hide();
-      state.score = 0, state.combo = 1;
-      updateStatus();
-      physics.initGame();
-      addRow() + addRow() + addRow();
-    }
-    state.ready = true;
-  }
-
-  function startGame() {
-    initGame();
-    state.ready = false;
-    physics.startGame();
-    Timeout.loop(function() {
-      addRow();
-      return nextTime();
-    }, nextTime());
-    state.playing = true;
-  }
-
-  function gameOver() {
-    state.playing = false;
-    updateStatus();
-    state.max = Math.max(state.max, state.score);
-    try {
-      localStorage.setItem(STORE_KEY, state.max);
-    } catch (e) {
-    }
-    physics.gameOver();
-    restart.show();
-    p2view.tween(100).pin('alpha', 0.5);
-    Timeout.reset();
-  }
-
-  function updateStatus() {
-    updateScore();
-  }
-
-  function updateScore() {
-    myscore.setValue(state.score);
-    maxscore.setValue(state.max);
-  }
-
-  function nextTime() {
-    return 8000 - 20 * state.score;
-  }
-
-  function addRow() {
-    var row = [];
-    for (var i = 0; i < 7; i++) {
-      if (Math.random() < 0.1) {
-        row.push({
-          type : 'none'
-        });
-        continue;
-      }
-      var color = [ 'b', 'r', 'y', 'g', 'p' ][Math.random() * 5 | 0];
-      var one = state.score + 1, four = Math.max(0, state.score * 1.1 - 60);
-      if (Math.random() < one / (four + one)) {
-        row.push({
-          type : 'normal',
-          color : color
-        });
-      } else {
-        row.push({
-          type : 'small',
-          color : color
-        });
-      }
-    }
-    physics.addRow(row);
-  }
-
-  function dropDown(brick) {
-    var random = Math.random();
-    if (random < 0.06) {
-      physics.dropDown(brick, '+');
-    } else if (random < 0.1) {
-      physics.dropDown(brick, '-');
-    }
-  }
-
-});
diff --git a/example/p2js-breakout/bg.png b/example/p2js-breakout/bg.png
deleted file mode 100644
index 2a22c398dfe92741cca7fc469c4b44570891086f..0000000000000000000000000000000000000000
GIT binary patch
diff --git a/example/p2js-breakout/index.html b/example/p2js-breakout/index.html
deleted file mode 100644
index a0a53b6..0000000
--- a/example/p2js-breakout/index.html
+++ /dev/null
@@ -1,23 +0,0 @@
-<!DOCTYPE html>
-<html><head>
-  <title>Break Out - Stage.js/P2.js</title>
-  <meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, width=device-width, height=device-height" />
-
-  <link href="../example.css" rel="stylesheet" />
-
-</head><body class="dark">
-  <div class="about">A <a href="https://github.com/schteppe/p2.js">P2.JS</a> &amp; <a href="http://piqnt.com/stage.js/">Stage.js</a> Example
-   - <a href="https://github.com/piqnt/stage.js/tree/master/example/p2js-breakout">Source</a></div>
-
-  <script src="../example.js"></script>
-  <script src="../../dist/stage.web.js"></script>
-
-  <script src="../dep/p2.js"></script>
-  <script src="../../ext/stage-p2.js"></script>
-
-  <script src="../dep/timeout.js"></script>
-
-  <script src="app.js"></script>
-  <script src="texture.js"></script>
-
-</body></html>
diff --git a/example/p2js-breakout/main.png b/example/p2js-breakout/main.png
deleted file mode 100644
index 0642cce9bcfcefffaf6183f1446c369a8e58dfcc..0000000000000000000000000000000000000000
GIT binary patch
diff --git a/example/p2js-breakout/texture.js b/example/p2js-breakout/texture.js
deleted file mode 100644
index b805616..0000000
--- a/example/p2js-breakout/texture.js
+++ /dev/null
@@ -1,49 +0,0 @@
-Stage({
-  image : { src : 'bg.png', ratio : 2 },
-  textures : {
-    'board' : { x : 0, y : 0,  width : 320, height : 416 }
-  }
-});
-
-Stage({
-  image : { src : 'main.png', ratio : 2 },
-  map : function(tex) {
-    tex.y = 256 - (tex.y + tex.height);
-    return tex;
-  },
-  textures : {
-    'br'         : { x : 32*0,  y : 0,   width : 32,  height : 32 },
-    'bg'         : { x : 32*1,  y : 0,   width : 32,  height : 32 },
-    'bb'         : { x : 32*2,  y : 0,   width : 32,  height : 32 },
-    'by'         : { x : 32*3,  y : 0,   width : 32,  height : 32 },
-    'bp'         : { x : 32*4,  y : 0,   width : 32,  height : 32 },
-
-    'brs'        : { x : 160,   y : 0,    width : 16,  height : 16 },
-    'bgs'        : { x : 176,   y : 0,    width : 16,  height : 16 },
-    'bbs'        : { x : 192,   y : 0,    width : 16,  height : 16 },
-    'bys'        : { x : 208,   y : 0,    width : 16,  height : 16 },
-    'bps'        : { x : 224,   y : 0,    width : 16,  height : 16 },
-
-    'paddleFull' : { x : 0,     y : 32,  width : 48,  height : 16 },
-    'paddleMini' : { x : 48,    y : 32,  width : 32,  height : 16 },
-    'ball'       : { x : 80,    y : 32,  width : 16,  height : 16 },
-    '+'          : { x : 96,    y : 32,  width : 16,  height : 16 },
-    '-'          : { x : 112,   y : 32,  width : 16,  height : 16 },
-
-    'restart'    : { x : 192,   y : 48,  width : 64,  height : 64 },
-
-    'd_' : {
-      '0' : { x : 16*0,  y : 48,  width : 16,  height : 16 },
-      '1' : { x : 16*1,  y : 48,  width : 16,  height : 16 },
-      '2' : { x : 16*2,  y : 48,  width : 16,  height : 16 },
-      '3' : { x : 16*3,  y : 48,  width : 16,  height : 16 },
-      '4' : { x : 16*4,  y : 48,  width : 16,  height : 16 },
-      '5' : { x : 16*5,  y : 48,  width : 16,  height : 16 },
-      '6' : { x : 16*6,  y : 48,  width : 16,  height : 16 },
-      '7' : { x : 16*7,  y : 48,  width : 16,  height : 16 },
-      '8' : { x : 16*8,  y : 48,  width : 16,  height : 16 },
-      '9' : { x : 16*9,  y : 48,  width : 16,  height : 16 },
-      ' ' : { x : 16*10, y : 48,  width : 16,  height : 16 }
-    }
-  }
-});
\ No newline at end of file
