CMSC132-Tetris-Game

Overview

For this project, you will implement code for the Tetris game. The graphical user interface has been provided to you in a package called gui. No part of the request involves you making any changes to code in this package. You will be implementing some of the functionality for the Tetris game by modifying classes provided to you in the model package.

Objectives

This project will allow you to practice two-dimensional arrays, abstract classes, inheritance, and test development.

Grading

Public Tests (50%)
Release Tests (40%)
Style (10%)

Code Distribution

You are provided with the following packages:

gui - Represents the graphical user interface for the game. Executing the main method of the GameGUI class in this package will launch the user interface (assuming your code compiles successfully).
model - Includes the classes you need to implement.
tests - Includes the public tests. You should add your student test class to this package.

Layout and Rotation

The layout of a tetromino represents its shape. When a tetromino rotates, its layout changes. Each tetromino has 4 layouts: up, left, down and right. When originally created, a tetromino is in the up layout. After one left rotation, it shifts to the left layout. After a second left rotation, it shifts to the down layout. After a third left rotation, it shifts to the right layout. Finally, after a fourth left rotation, it returns to a up layout. This sequence can be repeated by pressing z during game play. After going from the up layout to the up layout again, i.e in one full rotation through each 90 degree phase, all tetromino’s except from the I tetromino should occupy the same column coordinate as they did initially (If they have been moved down in during the rotation, their row coordinate may have changed). The I tetromino, however, should move left by one position after one complete counter-clockwise rotation. Therefore, the “rotation” of a I tetromino is really a translation, with each full rotation moving it one column closer to the left of the game board.

The diagram below shows the progression of each tetromino as you rotate counter-clockwise by 90 degrees.

Location

Although the layout of a tetromino is set (because its shape is set) for each of the 4 possible orientations, the location of a layed out tetromino will change due to rotation and moving the tetromino left/right. The diagram below illustrates this for the I tetromino.

Game Play

A random sequence of Tetrominos will fall down the playing field from the centre. The goal of the game is to fill the gaps horizontally. When an entire row is filled, the rows above it will collapse down by one row. A player can move a tetromino left/right using the corresponding arrow keys. They can also rotate the tetromino left (counter-clockwise) 90 degrees at a time by pressing the z key.

Specification

You are expected to implement methods for the Tetromino, I, J, L, O, S, T and Z classes. The other classes have been provided and you should not modify them. You should familiarize yourself with the Tetris Class.

Requirements/Project Policies

You may not add any classes, but feel free to add any instance variables and private methods you understand are necessary.
See Style Guidelines for information regarding style.
We cannot provide any information regarding release and secret tests. Once your project has been graded, you can see a TA if you would like to find out why you failed a release or secret test.

Testing

We encourage you to run the game GUI and interact with the game. However, such an interaction is not guaranteed to test the full range of your code. As such, we also encourage you to write student tests. Student tests demonstrating a particular issue you are encountering with your code will be requested upon seeking help during office hours.

Submission

To submit your project, zip the project folder and upload the zipped file to gradescope.

Tips on Getting Started

You have been provided with a class to represent each possible Tetris piece (a tetromino). We suggest that you start with the simplest tetromino (like O or I).