class Game {
constructor() {
this.x = 50;
this.y = 50;
}
render() {
ctx.fillStyle = "white";
ctx.fillRect(0, 0, canvas.width, canvas.height);
}
move() {
this.x += 10;
this.y += 10;
}
draw() {
ctx.fillStyle = "black";
ctx.beginPath();
ctx.arc(this.x, this.y, 10, 0, Math.PI * 2);
ctx.fill();
}
}
let game = new Game();
let canvas = document.getElementById("gameboard");
let ctx = canvas.getContext("2d");
for ( let i=0; i<100; i++){
game.render();
if (i % 10 == 0){
game.move();
game.draw();
}
}