This article describes the Js+canvas implementation of the Tetris game. Share to everyone for your reference, specific as follows:
Demo (not considered compatible with low version browsers):
**********************************************************************
September 3 Update:
Fixed a hidden, darker bug
Plus pause, one more function
Speed decreases with fractional increase
Add log Log
*********************************************************************
By writing this game harvest points:
1. The canvas Ispointinpath method does not support the FillRect, Strokerect context.
2. When canvas has an internal margin (padding), the coordinates of the incoming Ispointinpath method need to be subtracted from the padding value.
3. The method Json.parse (object) via JSON can quickly clone object objects, but note that cloning is still a reference relationship when there are methods in object objects.
Source:
Continuous optimization ...
More readers interested in JavaScript-related content can view this site: "JavaScript data structure and algorithm skills summary", "JavaScript Mathematical operational Usage Summary", "JavaScript switching effects and techniques summary", " JavaScript Search Algorithm Tips Summary, "JavaScript animation effects and tips Summary", "JavaScript Errors and debugging skills summary" and "JavaScript traversal algorithm and Skills summary"
I hope this article will help you with JavaScript programming.