首页 > 代码库 > 游戏写一半了

游戏写一半了

<!DOCTYPE html><html>	<head>		<meta charset=‘utf-8‘>		<title>games</title>		<style>			body{				background: aqua;				overflow: hidden;			}			.box{				width: 600px;				height: 400px;				background: cornflowerblue;			}			.box.bird{				width:50px;				height: 50px;				background: chartreuse;				text-align:center;				position: absolute;			}		</style>	</head>	<body>		<div class=‘box‘ id=‘mp‘>			<div class=‘box bird‘ id=‘bb‘>bird</div>		</div>		<script>			function init()			{				var oDiv = document.getElementById(‘bb‘);				oDiv.style.top=‘200px‘;				oDiv.style.left=‘100px‘;			}						function flyDown()			{				var v = 15;				var nowTop;				var down = setInterval(function(){					var fly = document.getElementById(‘bb‘);					nowTop=fly.offsetTop;					//alert(nowTop);					nowTop+=v;					var mmp=document.getElementById(‘mp‘);					if(nowTop-v>=+mmp.offsetHeight+mmp.offsetTop)					{						clearInterval(down);						alert("Game Over");					}					fly.style.top = nowTop+‘px‘;				},100);			}						function createEnemy()			{				var zhu = setInterval(function(){					var pos = Math.random() * document.getElementById(‘mp‘).offsetHeight ;					var Qup = document.createElement(‘div‘);						Qup.className = zhuzhi;						Qup.style.top=0;						Qup.style.left= 					var Qdown = document.createElement(‘div‘);						Qdown.className = zhuzhi;				},2*1000);			}						document.body.onclick=function()			{				//alert("hello");				var v = 100;				var num = 1;				var flyUp = setInterval(function(){					var fly = document.getElementById(‘bb‘);					nowTop=fly.offsetTop;					//alert(nowTop);					nowTop-=v;					nowTop=Math.max(nowTop,0);					//console.log(nowTop);					fly.style.top = nowTop+‘px‘;					num--;					//console.log(num);				if(num==0)				{					clearInterval(flyUp);					num=5;				}				},100);								}						init();			flyDown();					</script>	</body></html>

  

游戏写一半了