cgwalls
10-03-2008, 02:35 AM
Ok so i'm trying to make an object shoot a bullet but every time i shoot the bullet it's faster then the time before. I have no idea what's wrong with the code so if you guys have any ideas as to what's causing the bullet to speed up please tell me.
Here's the part of the code involving the bullet.
function keyListener(e){
if(!e){
e = window.event;
}
if(e.keyCode==32){
fireBullet();
}
}
function fireBullet(){
bullet.style.top = 305;
bulletTop = 305;
bullet.style.left = playerLeft + 12;
window.setTimeout("moveBullet();", 0);
}
function moveBullet(){
bulletTop -= 4;}
bullet.style.top = bulletTop;
window.setTimeout("moveBullet();", 0);
}
Thank You,
cgwalls
Here's the part of the code involving the bullet.
function keyListener(e){
if(!e){
e = window.event;
}
if(e.keyCode==32){
fireBullet();
}
}
function fireBullet(){
bullet.style.top = 305;
bulletTop = 305;
bullet.style.left = playerLeft + 12;
window.setTimeout("moveBullet();", 0);
}
function moveBullet(){
bulletTop -= 4;}
bullet.style.top = bulletTop;
window.setTimeout("moveBullet();", 0);
}
Thank You,
cgwalls