Unfinished JS works of two: the application of object-oriented thinking written Tetris

Source: Internet
Author: User
Tags table name
Practicing, written in the back of the mess, 8 (
More satisfied with the storage and rotation of the box, I have seen the same game of the most concise
<title> Tetris </title>
<script>
/********************************
Tetris Version 1.0beta
October 19, 2001 by Huang (Stone) (bbs.online.jx.cn)
This script can be used free of charge for any non-commercial purpose. Please retain the description of this paragraph when quoting.
Tetris version 1.0beta
by Li Huang, October 19th 2001
*******************************/
To store the shapes of each block
var Shapes = new Array (
New Array (2,1,0,0,1,0,2,0,1,1),
New Array (2,1,0,0,1,0,1,1,2,1),
New Array (2,1,1,0,2,0,0,1,1,1),
New Array (1,1,0,0,1,0,0,1,1,1),
New Array (2,1,0,0,1,0,2,0,0,1),
New Array (2,1,0,0,1,0,2,0,2,1),
New Array (3,2,0,1,1,1,2,1,3,1));
Function Tetris (name,width,height) {
This.width = width;
This.height = height;
document.write (' <table name= ' + name + ' id= ' + name + ' border=1 cellspacing=0 bgcolor= #C0C0C0 bordercolor= #C0C0C0 sty Le= "FONT-SIZE:12PT; line-height:12pt; " > ');
for (Var y=0;y<this.height;y++) {
document.write (' <tr> ');
for (Var x=0;x<this.width;x++)
document.write (' <td width=12 height=12> </td> ');
document.write (' </tr> ');
}
document.write (' </table> ');
This. Box = eval (name);
This.checkdot = function (x,y) {
if (x<0 | | y<0 | | x>=this.width | | y>=this.height)

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.