Schloool/Boxes

Aus ProgrammingWiki

Wiki-Quelltext dieser Seite.

<code>
var canvas;
var context;
var blocks;

function Box(y, color, speed) {
  this.x = 0;
  this.a = 25;
  this.y = y;
  this.color = color;
  this.speed = speed;

  this.render = function() {
    context.fillColor(this.color);
    context.fillRect(this.
  }
}

function init() {
  canvas = new Canvas(1);
  context = canvas.getContext("2D");
}

function tick() {
  blocks.forEach(function(block) {
    block["y"] += block["speed"];
  });
}

function render() {
  blocks.forEach(function(block) {
    block.render();
  });
}

function loopAnimation() {
  tick();
  render();
}

init();
runInterval("loopAnimation", 12);

</code>

<run>

</run>

<canvas w=600, h=300> </canvas>