Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
xingxinggeng committed Mar 14, 2018
1 parent 95efc66 commit 719e842
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 9 deletions.
Binary file added dist/pong.jar
Binary file not shown.
1 change: 1 addition & 0 deletions instructions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<html><p><br>Difficulty:<br>The Screen size increases with the difficulty that is chosen.<br><br>How To Play:<br><br>Player 1 uses W to move the paddle up,<br> S to move their paddle down, and A to grab the ball.<br>Player 2 uses the Up and Down arrows to move their paddle up and<br> down and the left arrow to grab the ball.<br><br>When ball is being held and the player releases it while moving their paddle up or down,<br>ball will be released with the same speed that the paddle is moving<br><br>Hit the space bar to move the ball initially.<br><br>Press P to pause the game.<br>Press M to return to the Main Menu.<br>You lose a life if you miss the ball.<br>When you lose a life, the total hits will be added to your opponents score.<br>The winner is the player with remaining lives.<br><br>Chaos Mode:<br> very small ball on large screen moving at faster than normal speed<br><br>Custom Mode:<br>Allows players to select both level and how many balls they would like<br>to be in play at one time at the level selected.<br><br>Information on Ball to Paddle Speed:<br>When ball is released, it has the same y-velocity as your paddle.<br>The ball increases in speed after each hit of paddle.</p></html>
Binary file not shown.
3 changes: 2 additions & 1 deletion src/edu/ucsb/cs56/projects/games/pong/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import edu.ucsb.cs56.projects.games.pong.menu.MainMenuUI;

import java.io.*;
import javax.swing.*;
import java.awt.*;

Expand Down Expand Up @@ -36,7 +37,7 @@ public Game(String title, Dimension dimension) {
/** main, entry point for game
* @param args not used
*/
public static void main(String[] args) {
public static void main(String[] args){
Game windowNew = new Game("Main Menu",getDIMENSION());
setWindow(windowNew);
MainMenuUI game = new MainMenuUI();
Expand Down
4 changes: 2 additions & 2 deletions src/edu/ucsb/cs56/projects/games/pong/gameplay/Screen.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ public void draw(Graphics g){
game.b[i].draw(g);
}

//If all the balls have stopped then pause the game
if(Pong.isPaused) {
//If all the balls have stopped then pause the game // change Pong.isPaused
if(game.checkBallStopped()) {
g.drawString( "Game Paused", Screen.w/2 - 100, Screen.h/2 - 100 );
g.drawString( "Press M to return to Main Menu", Screen.w/2 - 220, Screen.h/2 + 100 );
}
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.*;
import java.io.*;

/** edu.ucsb.cs56.projects.games.pong.menu.instructions.Instructions is the classs that displays the instructions to the game when the user presses the instructions button
@author Vincent Gandolfo, Krishna Lingampalli
Expand All @@ -15,7 +16,7 @@ public class Instructions{
JFrame jf;

/** Constructor that sets up the JFrame and Components that allow the instructions to be displayed */
public Instructions()
public Instructions()throws Exception
{
setUpFrame();
setUpFrameComponents();
Expand All @@ -35,7 +36,7 @@ public void setUpFrame()
}

/** setUpFrameComponents() sets up the layout on the frame and puts on the Instructions and the "Back To Main Menu" button */
public void setUpFrameComponents()
public void setUpFrameComponents()throws Exception
{
JButton backToMain = new JButton( "Back To Main Menu" );
backToMain.addActionListener( new BackToMainListener() );
Expand All @@ -57,10 +58,18 @@ public void setToVisible()
/** displayInstructions() displays the Instructions on how to play
* @return String returns instructions
*/
public String displayInstructions()
{
return ("<html><p><br>Difficulty:<br>The Screen size increases with the difficulty that is chosen.<br><br>How To Play:<br><br>Player 1 uses W to move the paddle up,<br> S to move their paddle down, and A to grab the ball.<br>Player 2 uses the Up and Down arrows to move their paddle up and<br> down and the left arrow to grab the ball.<br><br>When ball is being held and the player releases it while moving their paddle up or down,<br>ball will be released with the same speed that the paddle is moving<br><br>Hit the space bar to move the ball initially.<br><br>Press P to pause the game.<br>Press M to return to the Main Menu.<br>You lose a life if you miss the ball.<br>When you lose a life, the total hits will be added to your opponents score.<br>The winner is the player with remaining lives.<br><br>Chaos Mode:<br> very small ball on large screen moving at faster than normal speed<br><br>Custom Mode:<br>Allows players to select both level and how many balls they would like<br>to be in play at one time at the level selected.<br><br>Information on Ball to Paddle Speed:<br>When ball is released, it has the same y-velocity as your paddle.<br>The ball increases in speed after each hit of paddle.</p></html>");
public String displayInstructions()throws Exception
{
File file = new File("instructions.txt");
BufferedReader br = new BufferedReader(new FileReader(file));

String st = br.readLine();
return ("" + st);


/*return ("<html><p><br>Difficulty:<br>The Screen size increases with the difficulty that is chosen.<br><br>How To Play:<br><br>Player 1 uses W to move the paddle up,<br> S to move their paddle down, and A to grab the ball.<br>Player 2 uses the Up and Down arrows to move their paddle up and<br> down and the left arrow to grab the ball.<br><br>When ball is being held and the player releases it while moving their paddle up or down,<br>ball will be released with the same speed that the paddle is moving<br><br>Hit the space bar to move the ball initially.<br><br>Press P to pause the game.<br>Press M to return to the Main Menu.<br>You lose a life if you miss the ball.<br>When you lose a life, the total hits will be added to your opponents score.<br>The winner is the player with remaining lives.<br><br>Chaos Mode:<br> very small ball on large screen moving at faster than normal speed<br><br>Custom Mode:<br>Allows players to select both level and how many balls they would like<br>to be in play at one time at the level selected.<br><br>Information on Ball to Paddle Speed:<br>When ball is released, it has the same y-velocity as your paddle.<br>The ball increases in speed after each hit of paddle.</p></html>");*/
}


/** The action when the button "Back To Main Menu" is pressed. It just makes the frame not visible, so it appears to be closed and does not need to create a new instance of Instructions for every time the user clicks how to play */
class BackToMainListener implements ActionListener{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<html><p><br>Difficulty:<br>The Screen size increases with the difficulty that is chosen.<br><br>How To Play:<br><br>Player 1 uses W to move the paddle up,<br> S to move their paddle down, and A to grab the ball.<br>Player 2 uses the Up and Down arrows to move their paddle up and<br> down and the left arrow to grab the ball.<br><br>When ball is being held and the player releases it while moving their paddle up or down,<br>ball will be released with the same speed that the paddle is moving<br><br>Hit the space bar to move the ball initially.<br><br>Press P to pause the game.<br>Press M to return to the Main Menu.<br>You lose a life if you miss the ball.<br>When you lose a life, the total hits will be added to your opponents score.<br>The winner is the player with remaining lives.<br><br>Chaos Mode:<br> very small ball on large screen moving at faster than normal speed<br><br>Custom Mode:<br>Allows players to select both level and how many balls they would like<br>to be in play at one time at the level selected.<br><br>Information on Ball to Paddle Speed:<br>When ball is released, it has the same y-velocity as your paddle.<br>The ball increases in speed after each hit of paddle.</p></html>

0 comments on commit 719e842

Please sign in to comment.