CIS 120e Homework 10 - Make Your Own Game

Due Friday, December 10th, 2010 at 11:59:59pm; submissions allowed until Sunday, December 12th without late penalty.

Table of Contents

  1. Introduction: Pong (sort of)
  2. Extending Pong
  3. Your own game
  4. How to submit

Introduction: Pong (sort of)

For this assignment, your task will be to write your own game using the Java Swing GUI framework.

However, it would be cruel to ask you to write a game completely from scratch; even experienced Swing programmers start new programs by copying existing code, or by using a tool to automatically generate some code to start with. So, we've provided you with a very simple example game that you can use as a starting point if you like.

Pong

Our sample game is a very stripped-down version of Pong, the very first video game that ever was. There is a ball that bounces off the edges of the screen and a rectangular paddle, and you can move the paddle using the arrow keys. It doesn't do anything fancy like allow multiple players or keep score, but even such a simple program already demonstrates a lot of the key concepts you will need to make your own game. You should take a tour of the code provided before beginning to write your own game, though you are not required to use any of this in your own game. You can grab all the files together in SwingGame.zip.

You now have a choice: you may extend Pong, or create your own game. If you choose to extend Pong, you can earn a maximum of 70% credit, but we have provided a detailed outline of what you need to implement. If you choose to create your own game, the sky is the limit, and we will grade the game in part on its creativity and playability. Note that going through the exercises on extending Pong is an excellent way to start, even if you ultimately choose to morph it into your own game!

For this assignment, we strongly recommend that you make snapshots of your code periodically. Each time you get a new feature working, create a folder with the date and/or a descriptive title in its name (so you can remember which version is which if you have multiple snapshots), and copy all of your files into it. If your next big feature causes huge problems (or if the deadline arrives!), you'll have a way to recover a working version of your game to submit. Otherwise, you may find yourself a half hour before the deadline with a broken game that doesn't compile, and only half a head of hair (having pulled out the rest). As with previous assignments, if it doesn't compile, you get zero credit.

Extending Pong

The REAL Pong

There are a few features Pong is required to have. A very good way to start is to add these features to the simple Pong game. Then, if you wish, you can continue by changing it into your own game. To get 70% credit, you must implement four features: Instructions, Two-player ability, Updating score, and your choice of any one additional feature from the list below (and we suggest that you attempt to implement them in that order).

  1. Instructions: There should be some way of obtaining instructions/help. For example, you might add a button labeled "Help"; clicking this button would open a new window containing instructions giving the keys, how the score is kept, and anything else you think is important about Pong's game mechanics. Note: it should be possible to both read the instructions and play the game without restarting the program!
  2. Two-player ability: There should be two paddles, each of which can be controlled via the keyboard.
  3. Updating score: There should be a displayed score which automatically updates every time the score changes. One score should increase (by one) each time the ball hits the bottom of the court; another score should increase (by one) each time the ball hits the top of the court. (Or, if you wish, replace "bottom" and "top" by "left" and "right".)
  4. Ball control: In many implementations of Pong, the ball bounces off the paddle at different angles depending on where it bounces (for example, the ball bounces at a normal angle if it hits near the center of the paddle, but bounces at a much steeper angle if it hits near the edge of the paddle).
  5. Spin: If a paddle is moving at the moment the ball bounces off of it, the ball acquires spin which causes it to curve as it travels across the court.
  6. Mouse input: One of the paddles may be controlled both by the mouse and by the keyboard; as the mouse moves back and forth, the paddle should follow it.
Extending Pong with these features is worth a maximum of 70%.

Some hints:

Your own game

You're on your own! (Well, not quite; see below.) Your game will be graded partly on the required features, and partly on creativity and how much fun it is to play! That's right, to grade this assignment we are going to have a big party where we all sit around and play games projected on a giant screen. It's a rough life.

There are still two absolute requirements:

  1. an obvious way to get instructions for playing the game; this is also a great place to boast about the awesome features you've implemented that you want to make sure we don't miss;
  2. a score that is updated whenever the score changes; for board games like Othello or Connect Four, the score can be simply how many times each side has won.

Of course, coming up with a fun, original idea for a game can be hard; here are some suggestions. Feel free to implement any of these suggestions, or use them for inspiration. Of course, you should also feel free to completely ignore them and come up with your own, unique, super-awesome game. If you are wondering if some other combination of features will yield full credit, please post your questions on the BB. Extra credit may be given depending on how many extra features are included. Also, if you choose to make your own game, keep in mind how much work should go into it. Games such as Tic-Tak-Toe or Connect 4 are too easy to yield full credit.

Breakout

Breakout

Modifying the simple provided Pong game into a version of the classic game Breakout is a good option. As in Pong, you lose (a life) if the ball touches the edge of the screen behind your paddle. There is also a pattern of rectangular blocks; when the ball hits these blocks, they disappear. You win if you can cause all of the blocks to disappear, so you have to keep bouncing the ball off your paddle.

A well-done, bug-free version of Breakout with a score that updates as it changes, both mouse and keyboard control, multiple lives (with a display showing how many are left that updates appropriately), and at least three different colors would be worth full credit (though this is not the only combination of features worth full credit).

Space Invaders

Space Invaders In its simplest form, Space Invaders has a tank at the bottom of the screen and aliens at the top of the screen. The tank can move left and right as well as fire bullets towards the aliens; the aliens move horizontally across the screen, dropping vertically towards the tank each time one of them makes it to the edge of the screen. The player wins by destroying all the aliens, and loses by colliding with an alien.

A well-done, bug-free version of Space Invaders with a kill count and bullet count that update as they change, both mouse- and keyboard- controls, and aliens that look vaguely like aliens (or that look like anything other than rectangles!) would be worth full credit (though this is not the only combination of features worth full credit).

Reversi

Reversi Reversi (also marketed under the name "Othello") is a popular games played on a rectangular board. (See the above link for descriptions of the rules.) A program which allows two human players to play one of these games (or any other sort of board game) against each other could make a good project. (Note that writing a program which allows a human to play one of these games against the computer is quite difficult, and outside the scope of this assignment; although we won't stop you if you really want to!)

A well-done, bug-free version of Reversi with win counts for each player that update as they change, both mouse and keyboard control, and color graphics would be worth full credit (though this is not the only combination of features worth full credit).

Tetris

Tetris

Tetris is another classic game. Tetris is played on a grid; contiguous groups of four blocks drop from the top of the screen, stopping when they hit the bottom of the screen or when they hit the top of a previously dropped block. Any rows of the grid which are entirely filled with blocks at this point disappear; the game ends when a group of blocks can't enter the grid.

A well-done, bug-free version of Tetris with one-move lookahead that pauses when clicked, has a line count that updates as it changes, and has at least three colors would be worth full credit (though this is not the only combination of features worth full credit).

Battle City

Battle City

Battle City is another classic game. Here, we are asking you to implement a simple 2 players mode of Battle City. The battle city will consist of only walkable areas and bricks, and each player should try best to protect their own camp as well as to destroy another player's camp. Initially, the walkable areas and bricks should be randomly generated in between the two players' camps, and the camps should be wrapped by one layer of bricks. Please refer to the original Battle City game: Wikipedia. A compilable, well-done, bug-free version of Simplified Battle City for 2 players will earn full credit. Other cool playable features, including adding trees/water/ice into the city, may earn extra credit.

How to submit

You must submit a single archive called files.zip

The archive must contain all your sources; for those of you submitting projects that use additional libraries, the archive must also contain the requisite .jar files. If your project needs data to run—game level information, images, sounds, etc.—the archive must contain these as well. There must be a public class named Game with a public main function.

To run your game, we will execute the following command sequence from a terminal on the Moore 100A computers in a directory containing only your submitted archive; you may test there to make sure that you've created your submission correctly.

unzip *.zip 
javac *.java && java Game # we will add a classpath argument that
                          # includes any bundled .jar files

If your code doesn't compile, that second command will never get to your game... no-compile, no-credit!