闲来无事,花了两天时间,用javascript 写了一个打豆豆的游戏,至于怎么玩的就不细说了,到网上搜一下就知道了,很简单。
下面是源码,发布出来供大家学习交流。
由于本程序没有用到一个图片,所以界面在ie下豆豆都是方形的比较扎眼,建议用chrome浏览器运行,或者firefox
演示地址:http://pat") ? document.documentElement : document.body;
var sctop= document.documentElement.scrollTop||document.body.scrollTop;
fly_top=sctop+_doc.clientHeight
this.bot=fly_top-30;
setTimeout("paowuxian.dos("+i+")",20);
},
dos:function(i){
if(this._type[i].nt>this.bot){
if(this._type[i].sta==1){
document.body.removeChild(this.o[i]);
this._type.sta=-1;
}
}else{
this._type[i].l=this._type[i].l+3;
this._type[i].s++;
this._type[i].nt=this._type[i].t-5*this._type[i].s+0.5*1*this._type[i].s*this._type[i].s;
this.o[i].style.top=this._type[i].nt+'px';
this.o[i].style.left=this._type[i].l+'px';
setTimeout("paowuxian.dos("+i+")",20);
}
}
};
</script>
</body>
</html>
我是江奇
