A complete example of Tetris game implemented by JS + Canvas, canvas Tetris

Source: Internet
Author: User

A complete example of Tetris game implemented by JS + Canvas, canvas Tetris

This article describes the Tetris game implemented by JS + Canvas. We will share this with you for your reference. The details are as follows:

Try-on (compatibility with earlier browsers is not considered ):

**************************************** ******************************
Updated on April 9, September 3:
Fixed a hidden BUG.
Added the pause and repeat Functions
The speed decreases as the score increases.
Add log
**************************************** *****************************

Gains from writing this game:

1. The isPointInPath method of canvas does not support the context of fillRect and strokeRect.

2. When the canvas has an padding (padding), the coordinates of the input isPointInPath method must be subtracted from the padding value.

3. json. parse (JSON. stringify (Object) can be used to quickly clone an Object. However, when there are methods in an Object, the cloned Object is still a reference relationship.

Source code:

<! DOCTYPE html> 

Continuous optimization ......

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.