The simplified Tetris game consists of a 2D grid and 4 types of rectangle pieces. The rectangle pieces fall, one at a
time, onto the grid.
Users can move the rectangle pieces to the left and right as they fall. Once an entire row is
formed, the row collapses. The game ends when the stack of rectangle pieces reaches the top of the canvas and no
new rectangle pieces are able to enter.
In this assignment, you will create a canvas, which is a 2D grid. The height of the canvas is 240 and the width is
You will implement the following four rectangle piece (which are different from the tetrimino pieces in the
standard Tetris game):
Size: 20*20 Size: 40(L)*20(W) size: 60(L)*20(W) size:80(L)*20(W)
The rectangle pieces will appear randomly. You can use Math.random() and Math.floor() to randomly generate an
integer between 1 and 4, which is used to determine which rectangle piece will appear next:
You will also create two buttons (left and right) to control the movement of the rectangle pieces. The rectangle
pieces can be moved to two directions: left and right, by 20 unless it hits a wall or another rectangle pieces.
• Please hand in your source code electronically. The file name should be tetris.html.
• Write a README file (text file, do not submit a .doc file) which contains
▪ Names and email address of group members.
▪ (optional) anything special about your submission that the TA should take note of.
• Place tetris.html and README under one directory with a unique name (such as p3-[userid] for
assignment 3, e.g. p3-pyang).
• Tar the contents of this directory using the following command.
tar –cvf [directory_name].tar [directory_name]
E.g. tar -cvf p3-pyang.tar p3-pyang/
• Use mycourses to upload the tared file you created above.
Readme, correct file names: 4’
All students should follow Student Academic Honesty Code (http://watson.binghamton.edu/acadhonorcode.html).
All forms of cheating will be treated with utmost seriousness. You may discuss the problems with other students,
however, you must write your OWN codes and solutions. Discussing solutions to the problem is NOT acceptable.
Copying an assignment from another student or allowing another student to copy your work may lead to an
automatic F for this course. If you borrow small parts of code/text from Internet, you must acknowledge this in your
Also, you must clearly understand and be able to explain the material. Copying entire material or large
parts of such material from the Internet will be considered academic dishonesty. Moss will be used to detect
plagiarism in programming assignments. You need ensure that your code and documentation are protected and not
accessible to other students. Use chmod 700 command to change the permissions of your working directories before
you start working on the assignments. If you have any questions about whether an act of collaboration may be
treated as academic dishonesty, please consult the instructor before you collaborate.