Skip to content

Commit

Permalink
Reset the game after losing by clicking the mouse.
Browse files Browse the repository at this point in the history
  • Loading branch information
avh4 committed Oct 27, 2012
1 parent 3110a2f commit 30928dd
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/main/java/ScaryMazeGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import java.awt.image.BufferedImage;
import java.io.IOException;

public class ScaryMazeGame extends JComponent implements MouseMotionListener {
public class ScaryMazeGame extends JComponent implements MouseMotionListener,
MouseListener {

BufferedImage intro;
BufferedImage level1;
Expand Down Expand Up @@ -38,6 +39,7 @@ public static void main(String args[]) throws IOException {
window.setVisible(true);

game.addMouseMotionListener(game);
game.addMouseListener(game);
}

@Override
Expand Down Expand Up @@ -100,4 +102,28 @@ private void showGameOver() {
scream.play();
currentLevel = gameOver;
}

@Override
public void mouseClicked(MouseEvent e) {
if (currentLevel == gameOver) {
currentLevel = intro;
}
repaint();
}

@Override
public void mousePressed(MouseEvent e) {
}

@Override
public void mouseReleased(MouseEvent e) {
}

@Override
public void mouseEntered(MouseEvent e) {
}

@Override
public void mouseExited(MouseEvent e) {
}
}

0 comments on commit 30928dd

Please sign in to comment.