<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script>
var startTime;
var jishi;
var daijishi_id,start_id,xiaoshi_id,huanyuan_id;
var gameTime,start_but;
var zongfen=0;
var loudiao=0;
var isplay=true;
//出现地鼠
function start() {
var imgs = document.images;
var len = imgs.length;
var i = Math.floor(Math.random() * len);
imgs[i].src = "img/01.jpg";
start_id=setTimeout("start()", 500);
xiaoshi_id=setTimeout("xiaoshi(" + i + ")", 1000);
}
//开始游戏
function kaishi(){
var time=document.getElementById("shuru").value;
jishi=parseInt(time);
startTime=new Date();
daojishi();
start();
jinyong();
}
// 用户操作禁用
function jinyong(){
gameTime=document.getElementById("shuru");
start_but=document.getElementById("start_but");
if(isplay){
gameTime.disabled="disabled";
start_but.disabled="disabled";
}else{
start_but.removeAttribute("disabled");
gameTime.removeAttribute("disabled");
}
}
function daojishi(){
var playTime=new Date();
var lastTime=jishi*60-parseInt((playTime-startTime)/1000);
document.getElementById("xianshi").innerHTML=lastTime;
daojishi_id=setTimeout("daojishi()",1000);
if(lastTime<1){
clearTimeout(daojishi_id);
clearTimeout(start_id);
}
}
//停止按钮
function stop_but(){
clearTimeout(daojishi_id);
clearTimeout(start_id);
clearTimeout(xiaoshi_id);
var imgs=document.images;
for(var i=0;i<imgs.length;i++){
imgs[i].src="img/00.jpg";
}
isplay=false;
jinyong();
}
//漏掉
function xiaoshi(i) {
var img = document.images[i];
var imgName = img.src.substr(img.src.length - 6, 2);
if(imgName == "01") {
img.src = "img/00.jpg";
zongfen--;
loudiao++;
document.getElementById("defen").innerHTML=zongfen;
document.getElementById("loudiao").innerHTML=loudiao;
}
}
//打击地鼠
function daji(obj){
var name=obj.src.substr(obj.src.length-6,2);
if(name=="01"){
obj.src="img/02.jpg";
zongfen+=2;
document.getElementById("defen").innerHTML=zongfen;
xx=obj;
setTimeout("xx.src='img/00.jpg'",100);
}
}
</script>
</head>
<body>
<div style="float: left; margin-right: 30px;margin-top: 50px;margin-left: 30px;">
游戏时间:<input type="text" id="shuru"/>分<br /><br />
<button οnclick="kaishi()" id="start_but">开始游戏</button>
<button οnclick="stop_but()">停止</button><br /><br />
<div>
倒计时:<span id="xianshi"></span><br />
漏掉:<span id="loudiao"></span>只<br />
得分:<span id="defen"></span>
</div>
</div>
<table border="1px" style="margin-top: 20px;">
<tr>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
</tr>
<tr>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
</tr>
<tr>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
</tr>
<tr>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
</tr>
<tr>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
</tr>
</table>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script>
var startTime;
var jishi;
var daijishi_id,start_id,xiaoshi_id,huanyuan_id;
var gameTime,start_but;
var zongfen=0;
var loudiao=0;
var isplay=true;
//出现地鼠
function start() {
var imgs = document.images;
var len = imgs.length;
var i = Math.floor(Math.random() * len);
imgs[i].src = "img/01.jpg";
start_id=setTimeout("start()", 500);
xiaoshi_id=setTimeout("xiaoshi(" + i + ")", 1000);
}
//开始游戏
function kaishi(){
var time=document.getElementById("shuru").value;
jishi=parseInt(time);
startTime=new Date();
daojishi();
start();
jinyong();
}
// 用户操作禁用
function jinyong(){
gameTime=document.getElementById("shuru");
start_but=document.getElementById("start_but");
if(isplay){
gameTime.disabled="disabled";
start_but.disabled="disabled";
}else{
start_but.removeAttribute("disabled");
gameTime.removeAttribute("disabled");
}
}
function daojishi(){
var playTime=new Date();
var lastTime=jishi*60-parseInt((playTime-startTime)/1000);
document.getElementById("xianshi").innerHTML=lastTime;
daojishi_id=setTimeout("daojishi()",1000);
if(lastTime<1){
clearTimeout(daojishi_id);
clearTimeout(start_id);
}
}
//停止按钮
function stop_but(){
clearTimeout(daojishi_id);
clearTimeout(start_id);
clearTimeout(xiaoshi_id);
var imgs=document.images;
for(var i=0;i<imgs.length;i++){
imgs[i].src="img/00.jpg";
}
isplay=false;
jinyong();
}
//漏掉
function xiaoshi(i) {
var img = document.images[i];
var imgName = img.src.substr(img.src.length - 6, 2);
if(imgName == "01") {
img.src = "img/00.jpg";
zongfen--;
loudiao++;
document.getElementById("defen").innerHTML=zongfen;
document.getElementById("loudiao").innerHTML=loudiao;
}
}
//打击地鼠
function daji(obj){
var name=obj.src.substr(obj.src.length-6,2);
if(name=="01"){
obj.src="img/02.jpg";
zongfen+=2;
document.getElementById("defen").innerHTML=zongfen;
xx=obj;
setTimeout("xx.src='img/00.jpg'",100);
}
}
</script>
</head>
<body>
<div style="float: left; margin-right: 30px;margin-top: 50px;margin-left: 30px;">
游戏时间:<input type="text" id="shuru"/>分<br /><br />
<button οnclick="kaishi()" id="start_but">开始游戏</button>
<button οnclick="stop_but()">停止</button><br /><br />
<div>
倒计时:<span id="xianshi"></span><br />
漏掉:<span id="loudiao"></span>只<br />
得分:<span id="defen"></span>
</div>
</div>
<table border="1px" style="margin-top: 20px;">
<tr>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
</tr>
<tr>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
</tr>
<tr>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
</tr>
<tr>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
</tr>
<tr>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
<td><img src="img/00.jpg" width="60px" οnclick="daji(this)"/></td>
</tr>
</table>
</body>
</html>