A simple typing game written in JQuery

Source: Internet
Author: User
Tags erro

var off_x;   Horizontal axis var count=0;  Total Var speed=5000; Speed, default is 5 seconds.   var keyerro=0;   Input error number 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 array var arrcode=new array ();    for (Var i=65;i<=90;i++) {arrcode[i-65]=i;    }//random production of a letter Var randomchar=function () {off_x=math.random () *500+5;     //off_y=math.random () *500-10 in Div axis;  In Div ordinate var c=chararray[parseint (Math.random () *25)]; Randomly generate a letter var charhtml= "<div class= ' char ' id= '" +c+ "' style= ' Left:" +off_x+ "Px;color:" +colorbox () + ">" +c+ "<    /div> ";  $ ("#div1"). Append (charhtml);      };     var colorbox=function () {color=[];//use array to store the color style color[0]= "#ff2211";     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)];  Random color. }//Call some methods every three seconds to produce the letter function Accruechar () {//Put the random out in the animation queue Var _sildefun=[//Put the animation to be executed into an array in the function () {$ (' #div1 D       IV '). Animate ({top: ' +=470px '},speed,function () {//) Delete $ (this) when the animation finishes executing. Remove ();       count-=10;  $ ("input[type= ' text ']"). attr ({"Value": count});  });} ];  Put the function group in the Slidelist animation queue $ ("#div1"). Queue (' Slidelist ', _sildefun);    var _takestart=function () {//Remove a queue function from the front of the queue and execute 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 the pair to stop after a second $ ("#" +chararray[i]+ ""). Stop (). 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 ()"),/*******************************************html page ******************** /

  

A simple typing game written in JQuery

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.