CS 104 Project
100 points

Objective:   To gain experience with writing a complete program, combining techniques learned in class and to have fun!
Hypothesis:   The design of the program.
Solution:   A complete program with proper format and comments. A statement explaining how your hypothesis was tested and what you have learned in this process

Let's start the game!

For this project, you will design and implement a substantial game that combines the ideas you have learned in class. You have three options: you can implement a Tetris game, a Mine Sweeper game, or design and implement your own game.

Your project (worth 100 points) will be graded based on the following:

  1. The technical complexity of the game and the soundness of your implementation.
  2. The game behaves properly and naturally
  3. The creativity of the game design and the "fun factor".
  4. Your program should follow the above guidelines.

Option 1: The Tetris game

Write a program that implements the popular game Tetris. The game consists of two classes:

For extra credit, You may also implement an automated solver such that when the player clicks the mouse, the current game piece will be place in a proper position.

To allow the game to react to key presses, import java.awt.event.*, call addKeyListeners(); in the init or the run method, and use the following expression.

public void keyPressed(KeyEvent e){
    // press up botton, rotate
    if(e.getKeyCode() == KeyEvent.VK_UP) {
		...
    }
    // press left botton, shift left
    if(e.getKeyCode() == KeyEvent.VK_LEFT){
		...    }
    // press right button, shift right
    if(e.getKeyCode() == KeyEvent.VK_RIGHT) {
		...
    }
    // press down button, add speed 
    if(e.getKeyCode() == KeyEvent.VK_DOWN) {
		...
    }
  }

 

Below is a demo of what we have in mind.



Option 2: The Mine Sweeper Game

For this option, you will write a game in which a player explores and finds land mines in a field.

The game opens with a 10x10 grid of cells. 10% of the cells contain mines. The player play the game with the following options:

  1. Press the left button of the mouse in any unopened cell in the field opens the cell. If the cell contains a mine, it explores and the game is over. If the cell does not contain a mine, it is opened and displays the number of mines in the 8 cells surrounding it, unless there are no mines in the 8 cells surrounding it, in which case a chain reaction will start and open all nearby cells that do not contain mine.
  2. If the player decides that there is a mine behind an unopened cell, he or she can press the right button of the mouse in the cell, and a flag is placed on it. The flag can be removed by pressing the right button in the cell.
  3. The player wins the game by opening all cells that do not contain mine and flagging all cells that contain mine.

To distinguish the left button from the right button of a mouse event, import java.awt.event.*, call addMouseListeners(); in the init or the run method, and use the following expression. Note that you will need to explicitely extract the mouse point from the mouse event.

public void mousePressed(MouseEvent e) {
    ...
    double x = e.getPoint().getX();
    double y = e.getPoint().getY();
    if (e.getButton() == MouseEvent.BUTTON1) {
        ...
    } else {
        ...
    }
}

Below is a demo of what we have in mind.




Option 3: Design and Implement Your Own Game

There is no formal restrictions on what kind of game you write, however, you should following the following guidelines:

  1. The game should be graphical in nature (that is, the main program extends GraphicsProgram) and should contain animation.
  2. The game should be non-trivial, at least as complex as the latest lab assignments (such as lab 4).
  3. The program should require at least three classes (including the main class).
  4. The game should use RandomGenerator and the following graphical objects: GLabel, GRect (or GOval), GImage, GPolygon, GCompound.
  5. The game should react to mouse events (or key events).
  6. You need to discuss with me about the proposal of your game before starting, so that I can asses the scope and complexity of your project. You should bring a graph, a drawing, or a sample game (such as an arcade game, an internet game, or a console game) to the discussion.

For demonstration purpose and as an inspiration, take a look at games developed by the previous students as a project of CS104.

 

Games By Previous Students

There are some selected game programs developed by students at Lafayette College as a project of CS104: Game Programming.

Click on the screenshot to load the game. May require installation of Java plug-in.
 
Battle City
An old classic console game.
Helicopter Game
Lights Out
A classic electronic game.
Night Raid
Rat on a Scotter
Runner Game
Tower Defense