I am making a breakout game in javascript and I need to have 3 images to be the blocks, however I am having trouble with the image showing up at all. I also have another draw function in my code, and was wondering if this had anything to do with the problem. Below is my javascript code for drawing the image and my init function.
function init() {
ctx = $('#canvas')[0].getContext("2d");
intervalId = setInterval(draw, 10);
}
function draw() {
clear();
ctx.fillStyle = "#00A308";
ctx.fill();
rect(paddlex, paddley, paddlew, paddleh);
if (fireCircle()) {
circle((paddlex) + (paddlew/2), y, r);
}
}
var canvas = document.getElementById('canvas'),
context = canvas.getContext('2d');
home = new Image();
home.onload = function() {
context.drawImage(home, 100, 50);
}
home.src = "NavBarHome.png";