Teach you how to write js games-playing letters

Source: Internet
Author: User
Drop the letter and keyboard from the top, enter the letter, pass it correctly, and the next letter will know the number of key things written in this game. 1. onkeydown events. 2. onclick events when the mouse is pressed, click 3. vara (Math. random () * 500); Math. random generation of random... syntaxHighligh

Drop a letter from the top, enter a letter on the keyboard, and pass it correctly. The next letter is incorrect.

I know several key things when I write this game.

1. onkeydown event, when the mouse is pressed

2. For the onclick event, click

3. var a = (Math. random () * 500 );

Math. random () randomly generates 0-1 decimal places

4. String. fromCharCode (65 + (a * 100) % 26)

Convert a number to a char letter

5. event. keyCode

The value corresponding to the key pressed by the keyboard.

String. fromCharCode (event. keyCode)

6. setTimeout ("setHeight ()", 20 );

The number of millimeters per call .. Method

As long as you know about these games, the js games are basically the same.

---------------------- The following is my source code, which contains jquery, but the selector is used, so you don't need to thank document. getElementById (), others are useless -------------


 
<Br/> test <br/>

 
 

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.