CSCI_282_TetrisGame_Spring2021.pdf Tetris game: Semester project DR. CATHERINE ANDERSON XXXXXXXXXXMCNEESE STATE UNIVERSITY CSCI 282 XXXXXXXXXXOBJECT ORIENTED PROGRAMMING CHAPTER 1 Tetris game, Part 1...

2 answer below »
it should properly follow the UML diagram shown in the file.


CSCI_282_TetrisGame_Spring2021.pdf Tetris game: Semester project DR. CATHERINE ANDERSON MCNEESE STATE UNIVERSITY CSCI 282 OBJECT ORIENTED PROGRAMMING CHAPTER 1 Tetris game, Part 1 Implementing the game board for the game Tetris with animation spawning a series of pieces. TETRIS 1. Tetronimos 2. The game board 3. Scoring SECTION 1 The game Tetris is a game based on a tetromino, which is a shape con- structed with four (tetra) squares. There are seven unique ar- rangements of four bricks. By unique we mean that even with limitless rotation you cannot bring one unique shape to resem- ble another unique shape. The seven arrangements are shown below. An arrangement is valid only if each brick aligns with at least one another brick along its full side. In the game of Tetris, each of these shapes or tetrominos has a different color. Historically there is no “standard” color scheme. In fact, the very first game had all bricks the same color. My color scheme is shown below. The names you must use for each of the different Tetris bricks are shown below. : A.El B.Long C. Jay D.Ess E. Stack F. Zee G. Square 2 The game board is a grid, some times referred to as the well. During the game, tetris bricks appear in random order at the top of the well and fall towards the bottom of the well. During their fall, the player is allowed to rotate the shape by 90 de- grees each click. The player can also move the shape right or left. After each shape is as low as it can fall, it will freeze into place and a new shape will appear and being falling. The ob- ject of the game is to arrange the pieces at the bottom of the well such that no empty spaces occur. When a row across the well has been filled with brick segment, the filled row will disappear with all col- ored segments above it dropping to occupy the vacated row. The player scores 100 points for each single row that is cleared like this. If two rows are fill at once, 300 point are scored. Three rows at once scores 500 points and four rows scored at once is worth 1000 points. The game continues until a new brick has no free space in which to be placed. Alternate features (extra credit) 1. There can be a button that allows the player to increase the speed of the the falling shapes. For each increment of speed increase, the score for each combination of rows be- ing cleared goes up. 2. There can be a button that allows the player to “hard drop” a shape, which means it is positioned immediately at its low- est possible level. This allows more shapes to be places in an interval of time. 3 GAME FEATURES FOR PART 1 1. Game board with animated dropping shape 2. Shape must stop dropping at the bottom of the well. 3. New shape must appear and start dropping after current shape is at the bottom of the well 4. Order of pieces appearing must be random. SECTION 2 Evaluation Criteria for Tetris Game Part 1. For the implementation of this game you must adhere to sev- eral requirements that are imposed to give you practice in Ob- ject Oriented Design. You are expected to follow the UML dia- gram shown below. This will get you started on a good OOD (object oriented design). All classes must be present and used as indicated. I have given you method in each class that must be present, but you are free to create helper methods. I recommend that you adhere to the principle of “distinct purpose” when creat- ing methods. Each method should have a single purpose. If you cannot easily name the method, chances are that you are trying to do too much within the method. 4 Here is a description of the classes along with their appropri- ate methods. 1. TetrisWindow - Is a container for the game display and is a subclass of JFrame. This is the executable class and as such needs a main method. This class is responsible for the action listeners needed to run the menus that you will be adding in Part 3 of this assignment. The primary functional- ity of this class in part 1 is to instantiate both the Tetris- Game and the TetrisDisplay objects, and to provide a con- tainer for the GameDisplay to be housed in and seen. For this part, only the Constructor and the main method are re- quired. 2. TetrisDisplay - This class creates the graphic game dis- play by extending a JPanel. It is responsible for the event listeners for key clicks and for telling the game which moves were made by translating the key clicks. This class is also responsible for the animation. The only ‘data structure’ (term used loosely) needed in this class is a TetrisGame ob- ject. The class has a constructor that take a TetrisGame ob- ject as a parameter. The methods are: • processMove ()- called within the actionPerformed methods of the anonymous ActionListener defined for the Timer. It will call the games makeMove method and pass it the integer constant for DOWN (defined in the game class). • paintComponent(Graphics g) - will create the dis- play of the Tetris game. The Well and all bricks within the well should be drawn separately from the actively “falling brick”. 3. TetrisGame - This game contains all the logic for direct- ing the game; to • respond to the moves reported by the Tetris Display class, • update the game board and status after each move. • removes full rows and adjusts score • game end detection. The methods of the TetrisGame class are as follows: • initBoard( ) - Should reset each cell back to its “empty” condition, possibly -1. • spawnBrick( ) - Should randomly generate a new “falling brick”. • makeMove( int moveCode) - the move code should indi- cate which direction the falling brick should move; down, left, right, up, or rotate. For part 1, the only move is “down” • validateMove( ) - checks the tentative move to make sure the brick is in bounds. For part one, it simply has to check that the brick is not below the bottom of the well. 4. TetrisBrick (abstract class) - This is the superclass that contains all of the attributes and methods that all seven brick types bricks have in common. These will be inherited by its seven subclasses. There are several abstract methods that TetrisBrick must have that each subclass must over- 5 write. For part 1 of this project, the needed abstract method is initPositions. This must be overwritten is each subclass to allows each brick to start at the appropriate place for its shape. Each of the subclasses listed below must overwrite the ab- stract methods initPositions from the TetrisBrick class: El- Brick, JayBrick, EssBrick, ZeeBrick, SquareBrick, Line Brick and StackBrick. Progression of Assignments that will result in a com- plete Tetris game. The full Tetris game project will be due in three parts . The general functionality that will be due in each part is discussed in detail in each chapter of this manual. This is outlined be- low. Part 1: Create all of the classes in the UML and have them working together. The brick must be randomly generated and fall to the bottom of the well at which point it will disappear and a new brick appear at the time of the well. Part 2: Add key listeners that allow the user to move move the falling brick left and right as well as rotate it. boundary checking as well as color checking must be implemented. When the brick has fallen as far as it can without covering any other colored segment in the well, its shape must be trans- ferred to the well. A “new game” option must be available from hit the key ‘n’. Part 3: In this part, A full line must “dissappear” and the players score increase by 100 points. Menus must be in place to allow a user to save a current game to file and save a game along with tracking a leader board. The “new game “ options must also be avialable from the menu . Extra credit: Scoring multiple lines, multiple “hardness” lev- els to start game (faster drop rates), hard drop button. Any other extra feature will be considered for extra credit. Remem- ber, this is probably the first project you have been given in a Computer Science class. It can be used to show prospective employers what you are capable of, so it is recommended that you pay close attention to good programming form and com- pleting all of the extras will make your project stand out. Evaluation Criteria: You are expected to follow good programming form. You will loose substantial points for not doing so. Pay close attention to the “No numeric literals” conven- tion. This states that no numeric literals are allowed in code except to assign a value to a variable. the only exception to this are the values of 0,1 or 2. This is especially important when forming your graphics. You should assign needed values to variables from the start. There is never enough time at the end of a project to correct sloppy practices at the start of the project. You will loose sub- stantial points for not
Answered 4 days AfterMay 08, 2021

Answer To: CSCI_282_TetrisGame_Spring2021.pdf Tetris game: Semester project DR. CATHERINE ANDERSON...

Kamal answered on May 12 2021
144 Votes
Tetris/.classpath

    
    
    
Tetris/.project

     Tetris
    
    
    
    
        
             org.eclipse.jdt.core.javabuilder
            
            
        
    
    
         org.eclipse.jdt.core.javanature
    
Tetris/.settings/org.eclipse.jdt.core.p
refs
#Mon May 10 15:38:12 IST 2021
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
Tetris/bin/P/Tetris$1.class
package P;
synchronized class Tetris$1 implements java.awt.event.KeyListener {
void Tetris$1(Tetris);
public void keyTyped(java.awt.event.KeyEvent);
public void keyPressed(java.awt.event.KeyEvent);
public void keyReleased(java.awt.event.KeyEvent);
}
Tetris/bin/P/Tetris$2.class
package P;
synchronized class Tetris$2 extends Thread {
void Tetris$2(Tetris);
public void run();
}
Tetris/bin/P/Tetris.class
package P;
public synchronized class Tetris extends javax.swing.JPanel {
private static final long serialVersionUID = -8715353373678321308;
private final java.awt.Point[][][] Tetraminos;
private final java.awt.Color[] tetraminoColors;
private java.awt.Point pieceOrigin;
private int currentPiece;
private int rotation;
private java.util.ArrayList nextPieces;
private long score;
private java.awt.Color[][] well;
public void Tetris();
private void init();
public void newPiece();
private boolean collidesAt(int, int, int);
public void rotate(int);
public void move(int);
public void dropDown();
public void fixToWell();
public void deleteRow(int);
public void clearRows();
private void drawPiece(java.awt.Graphics);
public void paintComponent(java.awt.Graphics);
public static void...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here