JQuery writes a simple typing game that can prompt the correct and wrong number of times _jquery

Source: Internet
Author: User
Tags erro
var off_x; Horizontal axis var count=0; Total score var speed=5000; 
Speed, the default is 5 seconds. var keyerro=0; Input error times Var keyright=0; Enter the correct number of times/organization letter Var chararray=new Array ("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P" 
, "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"); 
Key-coded array var arrcode=new array (); 
for (Var i=65;i<=90;i++) {arrcode[i-65]=i; 
///random production of one letter Var randomchar=function () {off_x=math.random () *500+5;//in Div horizontal//off_y=math.random () *500-10;//in Div ordinate var c=chararray[parseint (Math.random () *25)]; Randomly generated one letter var charhtml= "<div class= ' char ' id= '" +c+ "' style= ' Left:" +off_x+ "Px;color:" +colorbox () + "' >" +c+ "< 
/div> "; 
$ ("#div1"). Append (charhtml); 

}; 
var colorbox=function () {color=[];/////////////////"#ff2211" with array of colors color[0]=; 
Color[1]= "#ff3311"; 
Color[2]= "#ff5511"; 
Color[3]= "#ff8811"; 
Color[4]= "#ffBB99"; 
Color[5]= "#1ff4f1"; 
Color[6]= "#ff5566"; 
Color[7]= "#668899"; 
Color[8]= "#99BBfA"; 
Color[9]= "#fECECC"; Return Color[parseint (Math.random () *10)];Randomly born color. ///Every three seconds call some methods to produce the letter function Accruechar () {///put the random out in the animation queue Var _sildefun=[//The animation to be executed in sequence in an array function () {$ (' #div1 di 
V '). Animate ({top: ' +=470px '},speed,function () {///when the animation is finished, delete $ (this). Remove (); 
count-=10; 
$ ("input[type= ' text ']"). attr ({"Value": count}); 
});} 
]; 
Put the function group into the Slidelist animation queue $ ("#div1"). Queue (' Slidelist ', _sildefun); 
var _takestart=function () {//Removes a queue function from the front end of the queue and executes it. 
$ ("#div1"). Dequeue ("Slidelist"); 

}; 
function Randcharhandle () {Randomchar (); 

_takestart (); 
} randcharhandle (); 
}//Health Code processing function KeyCode (event) {var keyvalue = Event.keycode; 
var Flag=false; 
alert (keyvalue); for (Var i=0;i<=arrcode.length;i++) {if (keyvalue==arrcode[i]&&$ ("#" +chararray[i]+ ""). Text ()!= "") {// 
Select pairs to stop for one second ("#" +chararray[i]+ ""). Stop (1000). Remove (); 
Choose the right to add 10 points count+=10; 
$ ("input[type= ' text ']"). attr ({"Value": count}); 

$ ("#right"). Text (keyright); 
Flag=true; 
Break 
} if (flag) {flag=false; 
keyright++; 

$ ("#right"). Text (keyright); }else{Keyerro++; 
$ ("#erro"). Text (Keyerro); 
} $ (function () {//Acceleration $ ("input[value= ' acceleration + + ']"). Click (function () {if (speed>0) speed-=1000; 

}); 
Deceleration $ ("input[value= ' deceleration--']"). Click (function () {speed+=1000; 


}); 
}); Window.setinterval ("Accruechar ()", 1500);

/*******************************************html page ***************************************************/

  
 
Related Article

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.