Notes:
This IS a pair assignment. You MUST do the assignment with your partner.
This work should be done in its own directory called 'psa9'. Instructions here.
This assignment has sample solution code that you can run on ieng6. .
Each file must have a header with the team members' names, logins, and PIDs. The header should also describe the program in 2-3 sentences.
This homework requires skills from Chapter 1 through Chapter 6.
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).
moveShapeDown,
moveShapeLeft, moveShapeRight, rotateCW, rotateCCW, collisionDetect,
moveShape, findLines, isFullLine, isEmptyLine, moveRows.
psa9
directory in your home directory. You must name your files as
indicated in
the problem descriptions for the turnin program to work.
Start by creating a directory (folder) in your ieng6 cs8fzz account (this is necessary for the bundle script). After you log in, create a directory by typing the commands:Go into that directory (like double clicking to open a folder) with the command:-bash-2.05b$ mkdir psa9Note: you must name your directories (folders) and files as indicated in the problem descriptions for the turn in program to work. Copy the files you need:-bash-2.05b$ cd psa9-bash-2.05b$ cp ~/../public/psa9/*.java .- The following links explain the files involved in this project:
- TShape.java -- Read and understand this first
- GameLogic.java -- This is what you're responsible for
- TextTris.java -- This is what you can use to test your code
- GamePanel.java -- Read this for more information about how the main game interacts with your classes
- In the graphical version of the game:
In the text version of the game, the instructions will be displayed to you per step
- down means to move the shape down at a faster rate
- right means to move the shape right
- left means to move the shape left
- a means to rotate the shape counter clockwise
- s means to rotate the shape clockwise
- Be sure to check the sample solution.
java TetrisWindowjava TetrisWindow -tjava TetrisWindow -djava TetrisWindow -g-t should come last as it actually starts the game in text mode. So
java TetrisWindow -d -g -tis ok, but
java TetrisWindow -g -t -dis not.
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
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.
The most challenging methods are probably shiftLinesDown and the collision detection. You may want to save those for last.
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.
This is a game! Try to have fun. Make your own blocks, put in your own colors, mess with the code, practice code ninjutsu.
This assignment is worth 20 points.The
GameLogicclass is graded out of 19 points:
- 2 Points -- For a proper implementation of
moveShapeDown- 1 Point -- For a proper implementation of
moveShapeLeft- 1 Point -- For a proper implementation of
moveShapeRight(note: moveShapeUp will not be graded)- 1 Point -- For a proper implementation of
rotateCW- 1 Point -- For a proper implementation of
rotateCCW- 4 Points -- For a proper implementation of
collisionDetect- 2 Points -- For a proper implementation of
findLines- 2 Points -- For a proper implementation of
shiftLinesDown- 1 Point -- For a proper implementation of
isEmptyLine- 1 Point -- For a proper implementation of
isFullLine- 3 Points -- For a proper implementation of
moveRowOne additional point applies:
1 Point -- For proper formatting. Proper formatting means that your code is properly and consistently indented. (You do not need to provide any additional comments for this assignment; however, you may do so if you wish.)
When you are ready to turn in your homework, runbundle-psa9from yourpsa9directory. 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-psa9again. 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 typingyand pressing theEnterkey.
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:(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
bash% scp -r psa9 cs8wxx@ieng6.ucsd.edu:"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.