Started work on the populating of asteroids
This commit is contained in:
45
simulation.js
Normal file
45
simulation.js
Normal file
@ -0,0 +1,45 @@
|
||||
var bg = document.getElementById("backgroundSim")
|
||||
var ctx = bg.getContext("2d");
|
||||
ctx.canvas.width = window.innerWidth;
|
||||
ctx.canvas.height = window.innerHeight;
|
||||
rock = new Image();
|
||||
rock.src = "Rock1.png";
|
||||
|
||||
ctx.fill()
|
||||
|
||||
function drawCircle(x, y, r){
|
||||
ctx.beginPath();
|
||||
ctx.arc(x, y, r, 0, 2*Math.PI)
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
particle = {
|
||||
x: 20,
|
||||
y: 20,
|
||||
r: 10,
|
||||
vx: 0.01,
|
||||
vy: 0.01,
|
||||
update: function(){
|
||||
self.x += self.vx;
|
||||
self.y += self.vy;
|
||||
},
|
||||
draw: function(){
|
||||
ctx.drawImage(rock, self.x, self.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
rock.onload = function(){
|
||||
let i = 0;
|
||||
while (i < 25){
|
||||
ctx.drawImage(rock, Math.random(1)*ctx.canvas.height,Math.random(1)*ctx.canvas.height);
|
||||
i += 1;
|
||||
}
|
||||
particle.draw();
|
||||
}
|
||||
|
||||
function Populate(){
|
||||
let particle
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user