JS in the game to play the Gopher

Source: Internet
Author: User
Tags gopher

<! DOCTYPE html>
<mata charset = "Utf-8"/>
<title> hit the ground mouse </title>
<style>
#tb {
Background:url (beijing.jpg) no-repeat;
}
#fen {
Font-weight:bold;
font-size:60px;
Font-family: mini simple haha;
}
#fen1 {
Font-weight:bold;
font-size:60px;
Font-family: mini simple haha;
}
</style>
<script>
function Kaishi () {
SetTimeout ("BH ()", 3000);
sum=0;
}
To achieve the action of the Hamster
function bh () {
Sj=math.floor (Math.random () *9);
Img1=document.getelementsbytagname ("img");
Img1[sj].src= "Dishu.gif";
Add a click event and strike action to a hamster picture
Img1[sj].setattribute ("onclick", "Daji ()");
SetTimeout ("xs ()", 1000);
}
To achieve the action of hitting the hamster, change the hamster picture to hit the picture, and remove the onclick event, to avoid the occurrence of a hamster hit two times, plus two times the condition of the score
function Daji () {
Img1[sj].src= "Shang.gif";
Img1[sj].removeattribute ("onclick");
Replace the image integrator plus a very
sum+=10;
Changing the Integrator
document.getElementById ("Fen"). INNERHTML=SUM/10;
document.getElementById ("Fen1"). Innerhtml=sum;
}
A second later, the gopher disappeared.
function xs () {
Img1[sj].removeattribute ("onclick");
Img1[sj].src= "Keng.gif";
SetTimeout ("BH ()", 1000);
}
</script>

<body onload= "Kaishi ()" >
<center>
<table id= "TB" >
<foction> hit the ground mouse </foction>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>

</table>
<p id= "Fen" > Hit Count </p>
<p id= "Fen1" > Score </p>
</center>
</body>

JS in the game to play the Gopher

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.