Problem Solving Assignment 9



Due Thursday, March 15 at 11:59pm PST


Notes:


This homework requires skills from Chapter 1 through Chapter 6.


There is no interview process required for this final PSA.

Problem

You and your partner will finish a project that will play a basic version of Tetris. Most of the code is provided for you. You do not need to read and understand all of the code to do this assignment. Read the individual readmes carefully. An overview of exactly what code you need to write is below.

The code provided for you can be copied from ~/../public/psa9. You will find some .java and .class files along with GameLogic.class. You need to modify only GameLogic.java and implement the required methods. The class files are the sample solution. In order to run it follow the instructions below (or simply hit: java TetrisWindow in the lab).

Introduction:

Details:

Running the program

java TetrisWindow
. . . runs the program without any options on
java TetrisWindow -t
. . . runs the program in text mode
java TetrisWindow -d
. . . turns on debug messages
java TetrisWindow -g
. . . turns on a background grid so you can check alignment
you can mix and match the parameters, but -t should come last as it actually starts the game in text mode. So
  java TetrisWindow -d -g -t
is ok, but
  java TetrisWindow -g -t -d
is not.

Testing Your Code

You can test your code by running TextTris or by running TetrisWindow with the -t flag. The instructions can be while running TextTris and should allow you to test every method that you need to write. This is the usage message that should appear

    Usage of TextTris: MAXIMIZE YOUR TERMINAL 
    a for movePieceLeft()     s for movePieceDown()    d for movePieceRight()    g for rotateCW()
    h for rotateCCW()         # for a particular piece v for findLines()         b for shiftLinesDown()
    p for put a random piece  x for System.exit        q for add a random line   w for add random blocks
    c for clear screen
    


Hints

  1. Start early and make use of the text mode for debugging your stuff. Text mode allows you to step through the game at EVERY step and lets you have a lot more control over the game than you would normally.

  2. The most challenging methods are probably shiftLinesDown and the collision detection. You may want to save those for last.

  3. Add your own debug messages for better use of the debug mode flag. My messages were only useful for me, but I've left them in as they may come in use for you.

  4. This is a game! Try to have fun. Make your own blocks, put in your own colors, mess with the code, practice code ninjutsu.

Grading Criteria

This assignment is worth 20 points.

The GameLogic class is graded out of 19 points:

One additional point applies:

How to turn in your homework electronically

When you are ready to turn in your homework, run bundle-psa9 from your psa9 directory. The session should look like this:

-bash-2.05b$ cd ~/psa9
-bash-2.05b$ bundle-psa9
Good; all required files are present:

	GameLogic.java

Do you want to go ahead and turnin these files? [y/n]y
OK.  Proceeding.


Performing turnin of approx. XXXX bytes 
Copying to /home/linux/ieng6/cs8w/turnin.dest/cs8wzz.psa9
.
Done.
Total bytes written: XXXX 
Please check to be sure that's reasonable.
Turnin successful.

If you want to make changes after you've turned in your homework, make the changes and run bundle-psa9 again. The program will warn you that a "previously turned-in file exists" and ask if "you wish to over-write this existing file" (delete the old version and replace it with this new one). Respond in the affirmative by typing y and pressing the Enter key.

Unix Tips

Copying the assignment directory to partner's home directory

You can copy the psa9 directory and its files to your partner's home directory by:

bash% scp -r psa9 cs8wxx@ieng6.ucsd.edu:

(don't forget the colon at the end of the command) where cs8wxx is your partner's username. You must be in the parent directory of the psa9 directory. So, you if you are currently in the psa9 directory you should execute "cd ..". Similarly, if the psa9 direcory is in your home directory then you have to be in your home directory. If you aren't there just execute "cd ~" and you'll be there. Your partner is required to enter his password when you enter the scp command. To check if the copy worked, your partner must login and ckeck if the psa9 directory exists in his home directory and if the proper files are located in it. This can be done by executing: "ls ~/psa9". The files in the psa9 directory should be listed.