Simple typing Games Written by jQuery can prompt correct and wrong times _ jquery

Source: Internet
Author: User
Tags erro
This article mainly introduces the number of times that simple typing games written using jQuery can prompt correct and wrong messages. For more information, see
Var off_x; // the abscissa var count = 0; // The total var speed = 5000; // The speed. The default value is 5 seconds. var keyErro = 0; // input error count var keyRight = 0; // enter the correct number of times // The 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"); // Array of key code var arrCode = new Array (); for (var I = 65; I <= 90; I ++) {arrCode [i-65] = I;} // randomly generate a letter var randomChar = function () {off_x = Math. random () * 500 + 5; // At the abscissa of p // off_y = Math. random () * 500-10; // in the p ordinate var c = charArray [parseInt (Math. random () * 25)]; // generates a random letter var charHtml ="

"+ C +"

"; $ (" # P1 "). append (charHtml) ;}; var colorBox = function () {Color = []; // use an 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] = "#99 BBfA"; Color [9] = "# fECECC"; return Color [parseInt (Math. random () * 10)]; // random color .} // call several methods every three seconds to produce the function accrueChar () {// place the random output in the animation queue var _ sildeF Un = [// put the animation to be executed into an array in sequence function () {$ ('# p1 p '). animate ({top: '+ = 470px'}, speed, function () {// Delete $ (this) when the animation is executed ). remove (); count-= 10; $ ("input [type = 'text']"). attr ({"value": count}) ;}]; // put the function group in the slideList animation queue $ ("# p1 "). queue ('slidelist', _ sildeFun); var _ takeStart = function () {// remove a queue function from the front end of the queue and execute it. $ ("# P1 "). dequeue ("slideList") ;}; function randCharHandle () {randomChar (); _ takeStart () ;}randcharhandle () ;}// key 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 ()! = "") {// Click the right button to stop a second $ ("#" + charArray [I] + ""). stop (1, 1000 ). remove (); // Add 10 points count + = 10 for the selected pair; $ ("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 );

/*************************************** ********************************** *****************/

  
  

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.