I have an image loaded on the canvas, however it has made a duplicate of it and there are two. And the image does not move at all on command either. Please help
let img = document.getElementById("ship");
let player = {
x: 375,
y: 550,
w: 50,
h: 50,
};
requestAnimationFrame(draw);
function draw() {
ctx.drawImage(img, 5, 5);
ctx.img(player.x, player.y, player.w, player.h);
//Draw
//Request another frame
requestAnimationFrame(draw);
}
document.addEventListener("keydown", move);
function move(event) {
if (event.code == "ArrowRight") {
player.x = player.x + 50;
}
}