iLMS知識社群(Sites)師生部落格(Blogs)朝陽首頁(Homepage)TronClass教學平台登入
位置: 王士豪 > 未分類
12313
by 王士豪 2018-11-05 09:54:40, 回應(4), 人氣(25)
http://www.cyut.edu.tw/~s10514153/games/car/
回應(4)
<!DOCTYPE html>
<html lang="en">
<head>
  <title>Mouse Go!</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <script>
var myVar = setInterval(myTimer, 600);
var STOP = setTimeout(Stoppppp, 30000);
    var b=0,c=0,s=0,zzz,pid,aaa,stoppp=1;
//z=Math.floor(Math.random()*3)+3;
//aaa='z'+z;
function myTimer() {
if(c>0) document.getElementById(pid).src = "2.jpg";
c++;
    s=Math.floor(Math.random()*9)+1;
zzz=s;
var sid='z'+s;
pid=sid;
document.getElementById(sid).src = "1.jpg";
/*if(c/3==1) document.getElementById("ok").src = "1.jpg";
else if(c/5==1) document.getElementById("ok").src = "3.jpg";
else if(c/2==1) document.getElementById("ok").src = "4.jpg";
else     document.getElementById("ok").src = "2.jpg";*/
}
function Stoppppp(){

clearTimeout(myVar);
stoppp=0;
document.getElementById("id_score").innerHTML="Game Over~"+"("+b+")";
}
  
    function Score(apple) {
    if(apple==zzz && stoppp==1) b++;
document.getElementById("id_score").innerHTML ="Score:"+b;
}
  
  </script>
  
  
  
</head>
<body>

<div class="container">
  <h2 id='id_score'> Mouse Go!!!</h2>
<table class="table">
<tbody>
<tr>
<td><img id='z1' onclick='Score(1)' src='2.jpg' class="img-rounded" alt="Cinque Terre" width="250" height="250"></td>
<td><img id='z2' onclick='Score(2)' src='2.jpg' class="img-rounded" alt="Cinque Terre" width="250" height="250"></td>
<td><img id='z3' onclick='Score(3)' src='2.jpg' class="img-rounded" alt="Cinque Terre" width="250" height="250"></td>
<tr/>
<tr>
<td><img id='z4' onclick='Score(4)' src='2.jpg' class="img-rounded" alt="Cinque Terre" width="250" height="250"></td>
<td><img id='z5' onclick='Score(5)' src='2.jpg' class="img-rounded" alt="Cinque Terre" width="250" height="250"></td>
<td><img id='z6' onclick='Score(6)' src='2.jpg' class="img-rounded" alt="Cinque Terre" width="250" height="250"></td>
<tr/>
<tr>
<td><img id='z7' onclick='Score(7)' src='2.jpg' class="img-rounded" alt="Cinque Terre" width="250" height="250"></td>
<td><img id='z8' onclick='Score(8)' src='2.jpg' class="img-rounded" alt="Cinque Terre" width="250" height="250"></td>
<td><img id='z9' onclick='Score(9)' src='2.jpg' class="img-rounded" alt="Cinque Terre" width="250" height="250"></td>
<tr/>
  
 
  
</div>

</body>
</html>

  <script>  //倒數計時
var countdownnumber=29;
var countdownid,x;
function initial(){
  x=document.getElementById("countdown");
  x.innerHTML=countdownnumber;
  countdownnumber--;
  countdownid=window.setInterval(countdownfunc,1000);
}
function countdownfunc(){ 
  x.innerHTML=countdownnumber;
  if (countdownnumber==0){
    alert("遊戲結束");
    clearInterval(countdownid);
  }
  countdownnumber--;
}
</script>
倒數時間:
<div id="countdown"> </div> 
onload="initial();"

回應