# Why Won't Image Drawing Work In JavaScript

In my game at the beginning the first thing that you'll see is a campfire with this code:

 var campfire = new Image();
ctx.drawImage(campfire, campfireX, campfireY);
};
campfire.src = "Sprites/Campfire.png";


However, it doesn't work, I put an

alert("All systems a-ok");


at the end and i get the alert so i don't understand why it's there. You can find the actual image file here and the full code here. Sorry if I didn't format this well or something, I'm not very good at this =3

This may seem similar to an older question of mine in which I stated how to add a sprite onto the canvas, though in this case, I'm asking why the image doesn't appear on the canvas at all, even though there's no errors.

– Neil
Jan 7 '17 at 11:57

You should use this (literally):

var campfire = new Image();