try changing your function CreateBullet(startX, startY) to this:
function drawBullets(jet, bullets) {
for (b in bullets) {
b.update();
ctxBullet.drawImage(bulletImage, jet.getX(), jet.getY());
b.move(1, 0);
}
}
function CreateBullet(startX, startY) {
return {
x: startX,
y: startY,
getX: function () {
return this.x;
},
getY: function () {
return this.y;
},
update: function () {
ctxBullet.clearRect(0, 0, 800, 600);
},
move: function (dx, dy) {
this.x += dx;
this.y += dy;
}
}
}
i just noticed that you are drawing all the bullets on the draw method, not sure if this is causing the freezing, but it's better to just move it out before it causes a infinite loop...
what i did to your CreateBullet function was change it to make use of javascript object notation. this is really intrusive on your code, but i can explain better what was happening...
each time that you use a line like this:
Bullet.prototype.something = ...
you are adding the function/variable to the Bullet function prototype.
what does that mean? well, in javascript, even functions are objects. in this line:
var Bullet = function(){}
you're saying that Bullet is a function with no body. when you use
return new Bullet();
you are calling the function Bullet, that does nothing and returns undefined.
now, with the JSON notation i provided above, you are returning an object that has all the things defined between the { and }, even the variables.
this approach is more simillar to java, so you should get it better...
again, i'm no professional javascript programmer, i only use it on web projects, so i may be missing something.