Home
Important Dates Grading Lectures Optional Readings
Exercises Group Assignments Individual Assignments
Exam Schedule
Videos Slides
College of Engineering Aeronautics and Astronautics Agricultural and Biological Engineering Biomedical Engineering Chemical Engineering Civil Engineering Construction Engineering and Management Electrical and Computer Engineering Engineering Education Engineering Professional Education Environmental and Ecological Engineering Industrial Engineering Materials Engineering Mechanical Engineering Nuclear Engineering
EPICS (Engineering Projects In Community Service) First-Year Engineering Program First-Year Engineering Honors Program Global Engineering Program Minority Engineering Program Professional Practice (Co-Op) Program Women in Engineering Program
College Administration Schools Programs All Groups All People ECN Webmail
Purdue Home

ECE 462 Group Assignment

Stage 2: Interactive Tetris Game

Deadline: 11:59PM 2009/10/18

Summary

This stage creates an interactive Tetris game. Each piece (also called pieces or tetrads) has 4, 5, 6, or 7 squares. Your game has to implement

  • generate the next piece by randomly selecting one of all possible pieces
  • respond to user input for rotation, horizontal movement, and immediately drop to the bottom
  • determine whether a piece can rotate or move
  • eliminate a line if it is completely filled
  • detect whether the game is over
  • show the score
  • pause/resume game
  • implement demo mode that has an ability to eliminate lines
  • run as both an Application and an Applet

Possible pieces

Teams will compete in stage 4. To make competitions possible, all teams must agree on the same set of rules. This file is the list of all possible pieces, represented by their numbers and orientations. Your program must use these pieces, in their orders and orientations.

Command-Line Options

To help you develop and debug the program, the following command-line options are required.

  • -f filename: -f followed by a string to specify an input file that contains a finite sequence of pieces.  The file format is described in next section.

Input File Format

The input file consists of N lines, where N is the number of pieces.  Each line contains the "encoded piece data" for one piece, where the "encoded piece data" is the encoded 0/1 string you got in Stage 1 [Review].

For example, for a T shape 4-square piece:

***.      1110
.*..  ->  0100
....      0000
....      0000

The original encoded string for this piece as described in Stage 1 is:

1110010000000000

This is the line for this T shape piece.

Do not generate the pieces in your program if your program is run with the -f switch.  Your program must use the pieces in the same order and shapes given in the file.  Here are some sample inputs:  input1, input2

Game Components

Interactive Super Tetris (or Tetrix) is a 2-dimensional board game.  The program consists of a main window which contains the following components:

  • Playground: Since the pieces have more squares, the playground is enlarged to 20 (width) x 30 (height).  Pieces are rendered in the playground and can be either monochrome or colorful.
  • Next piece panel: There is a panel that displays the piece which is about to enter the playground.  If there is no piece left (when using an input file and EOF is reached), make the panel blank.
  • Status: Your program must display the status of the game, including the following iteams
    • Number of lines eliminated.
    • Total number of pieces that have entered the playground
    • Numbers of 4, 5, 6, and 7-square pieces that have entered the playground (four different numbers)
    • Total number of squares from these pieces
  • Buttons and/or menu items that can pause, quit the game, switch between Play Mode and Demo Mode and configure keys.

Game Rules

Most of the game rules are in compliance with the original Tetris game:

  • Only four operations are used for the Tetris game: Left, Right, Rotate and Fall (soft drop, which means the piece is moved down by only one square).  The corresponding keys can be configured by a button (or menu item).
  • Left and Right operations move the current piece to the left or right by one square.
  • Rotate operation rotates the piece by 90 degrees clockwise.  If any square of a rotated piece is going to overlap an existing square in the playground, the rotation operation is void.  This is the only constraint for rotation.
  • Fall operation causes the piece to move down by one square.  If the piece cannot move down, then this operation makes it fixed on the playground and the next piece shows up at the top.
  • 0.5 second after the last Fall operation, a new Fall operation is forced by a timer.
  • A complete line is eliminated from the playground and the squares above are shifted down.

Grading

The full score of this stage is 6 points, divided into the following items.

Program Functionality (4.8pt)

  1. (0.5pt) Graphical user interface - The programs runs, showing a window with a playground (20x30), a panel displaying the next piece, status labels (as described in Game Componenet section) and buttons (or menu items) for Pause/Resume, Quit, Demo/Play Mode and Configure Keys.
  2. (not required) Dual-launchability - The program can be run as both an Application and an Applet (which can be embedded into a web page).  The user interfaces along with the functionalities in both modes must be identical.
  3. (1.0pt) Key configuration - When the "Configure Key" button (or menu item) is clicked, a modal dialog appears and allows player to assign a key to each operation (Left, Right, Rotate, Fall).
  4. (1.2pt) Piece movement
    • If there is no player input, the piece falls every 0.5 second.
    • The piece can be moved to the left or right according to player input (keyboard).
    • The piece can be rotated by player, provided that it will not collide with existing squares (fixture).
    • The falling piece is fixed if it can no longer fall down.
  5. (0.5pt) Line elimination - If a line is completely filled with squares, it is eliminated from the playground.  all fixed squares above the eliminated line(s) are shifted down by a corresponding number of the lines.
  6. (0.5pt) Game statistics - labels correctly count the
    • number of lines eliminated.
    • total number of pieces that have entered the playground
    • numbers of 4, 5, 6, and 7-square pieces that have entered the playground (four different numbers)
    • total number of squares from these pieces
  7. (0.3pt) Gameover message - If the initial position of a new piece already overlaps an existing square, the game is over, and a message is displayed.  If user dismisses the message, the playground along with statistical data is reset for a new game.
  8. (0.8pt) Demo mode - A button (or menu item) allows the program to switch between Play mode (responsive to player input) and Demo mode (irresponsive to player input).  In Demo mode, pieces are automatically rotated, moved and placed in the playground.  Strategy used in Demo mode must be able to eliminate at least one line in a relatively limited time span.

Program Readability (1pt)

Coding Style (0.5pt)

  1. (0.1pt) The code is formatted uniformly with proper indentation.  Make your code look beautiful and professional. Use code formatter in your IDE (both NetBeans and Eclipse provide such function).
  2. (0.2pt) Classes, objects and members are named under coding conventions. There are several conventions for your choice to follow:
    As there are many existing conventions for C++ coding, the principle of your coding style is to be consistent, understandable and easy to read.
  3. (0.2pt) There should be explanatory comments to help reader understand your code. Also, give a brief description about the class at the beginning of each class file.

Documentation (0.5pt)

  1. (0.2pt) Analyze the data structure you use for the playground, piece.  Describe how you pass the key-pressed event message to the playground and make the piece move.
  2. (0.2pt) Explain how your program works, what functions every class/object provides, etc.
  3. (0.1pt) Explain how your code is prepared for the next stage of development, i.e., what part of the code can be reused and how to extend your program to fulfill the requirements in the next stage.

Evaluation (0.2pt)

You will be asked to fill in an evaluation form to evaluate the performance of each team member (including yourself).  This category will depend on the result of the evaluation from you and your partners.  The aspects of the evaluation include

  • providing meaningful contributions to the assignment (ideas, coding techniques, etc.)
  • writing readable and maintainable code (coding style, comments and documentation style)
  • attitude toward group affairs (organizing/attending group meetings, assigning duties, working cooperatively, etc.)

You will get 0.2 point if you finish the evaluation form.  The evaluation form should be submitted as an attachment along with your project files on Blackboard.

Bonus (0.5pt)

  1. (0.5pt) Post a one-minute or longer demonstration on a public web site (such as YouTube).  Please include the URL in your submission.

External SVN Server

If you prefer to use SVN, instead of CVS, you may use one of many external svn servers. You can find a list of svn servers at this site. Please choose the one you prefer. You need to provide evidence that you are using version control.  When you submit your project, please include a file called SVN and it includes (1) the URL of the project on the server and (2) the commit history.  If you use an external svn server, please share your experience by posting in Blackboard - Discussion.

If you prefer to use SVN using your local course account and the ECN assigned groups, you can submit a zip file packing everything in the SVN repository directory.