大神帮忙解决!!!!!子弹不跟随飞机移动
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
.div{ border:2px solid #000; position:relative; width:1200px; height:900px; background-image:url(bj.jpg);}
#div1{ width:80px; height:100px; position:absolute; z-index:2; background-image:url(fj.png); left:600px; top:800px;}
</style>
<script>
function zidan()
{
}
document.onkeydown=function(ev)
{
var oEvent=ev || event ;
var oDiv=document.getElementById("div1");
var oDiv1=document.getElementById("div2");
//alert(oEvent.keyCode);
//上 38 下 40 左37 右39 空格 32
if(oEvent.keyCode==37)
{
if(oDiv.offsetLeft<50)
{
oDiv.style.left=0;
}else
{
oDiv.style.left=oDiv.offsetLeft-15+'px';
}
}else if(oEvent.keyCode==39)
{
if(oDiv.offsetLeft>1110)
{
oDiv.style.left=1010;
}else
{
oDiv.style.left=oDiv.offsetLeft+15+'px';
}
//alert(oDiv.offsetLeft);
}else if(oEvent.keyCode==38)
{
if(oDiv.offsetTop<50)
{
oDiv.style.top=0;
}else
{
oDiv.style.top=oDiv.offsetTop-15+'px';
}
}else if(oEvent.keyCode==40)
{
if(oDiv.offsetTop>790)
{
oDiv.style.top=900;
}else
{
oDiv.style.top=oDiv.offsetTop+15+'px';
}
}else if(oEvent.keyCode==32)
{
var aDiv=document.createElement("div");
aDiv.style.width=20+'px';
aDiv.style.height=26+'px';
aDiv.style.backgroundImage='url(zidan.png)';
aDiv.style.position="absolute";
aDiv.style.left=30+'px';
oDiv.appendChild(aDiv);
aDiv.style.top=0+'px';
parseInt(aDiv.style.top);
setInterval(function(){
aDiv.style.top=aDiv.offsetTop-10+'px';
},30);
if(aDiv.style.top<0)
{
aDiv.style.position="static";
return;
}
}
}
</script>
</head>
<body>
<center>
<br />
<br />
<div class="div" id="div2"><!--大-->
<div id="div1"></div><!--小-->
</div>
</center>
</body>
</html>