UNPKG

js1k-harness

Version:

Tools for developing js1k entries

26 lines (20 loc) 682 B
// This is your js1k entry. This script will be minified and stripped of comments. // The following variables are available to this script: // a: <canvas> 2d drawing context // b: document.body // c: <canvas> DOM element var SIZE = 700, velx = 0, vely = 0; var x = SIZE/2, y = SIZE/2, mass = 50; c.width = c.height = SIZE; a.fillStyle = 'rgba(200,200,250,0.2)'; a.strokeStyle = 'rgba(0,0,200,1)'; setInterval(function() { force_x = Math.random()*100 - 50; force_y = Math.random()*100 - 50; velx += force_x/mass; vely += force_y/mass; x = x+ velx*0.4 y = y+ vely*0.4 a.fillRect(x, y, 100, 100); a.strokeRect(x, y, 100, 100); }, 200);