var Asteroid = function(x, y, size, angle) { AST_SPEED = 1 + Math.random() * .7; this.SIZES = [7,13,26]; this.type = Math.floor(Math.random()*2); this.size = size; this.x = x; this.y = y; this.dx = AST_SPEED * Math.cos(angle); this.dy = AST_SPEED * Math.sin(angle); this.radius = this.SIZES[size]; } Asteroid.prototype.draw = function(ctx) { //TODO: if close to the edge, draw two asteroids ctx.beginPath(); //ctx.arc(this.x,this.y,this.SIZES[this.size],0,2 * Math.PI,true); arr = [[[-6,-1],[-1,-6],[3,-6],[6,-1],[6,2],[3,6],[0,6],[0,2],[-3,6],[-6,3],[-3,0],[-6,-1]], [[-6,-3],[-3,-6],[-1,-5],[1,-5],[3,-6],[5,-3],[3,-1],[5,1],[5,3],[2,6],[-1,4],[-2,4],[-3,5],[-4,5],[-6,3],[-6,2],[-5,1],[-5,-1],[-6,-2],[-6,-3]]]; //TODO: 3rd, fix 2nd flag = 0; for (i=0;i