Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
iamSamuelFu committed Mar 13, 2018
1 parent 757ad4e commit 95efc66
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
21 changes: 13 additions & 8 deletions src/edu/ucsb/cs56/projects/games/pong/gameplay/Ball.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ public void holdBallToPaddle(KeyEvent evt, double distance)
setAttached(true);
setSpeedX(getXVelocity());

if(evt.getKeyCode() == KeyEvent.VK_A && ( (int)(distance+50) < (DifficultyLevel.getPaddleHeight()) ) ) {
if(evt.getKeyCode() == KeyEvent.VK_A && ( (int)(distance+35) < (DifficultyLevel.getPaddleHeight()) ) ) {
stopBall();
paddle = false;
}

if(evt.getKeyCode() == KeyEvent.VK_LEFT && ( (int)(distance+40) <(DifficultyLevel.getPaddleHeight()) )) {
if(evt.getKeyCode() == KeyEvent.VK_LEFT && ( (int)(distance+45) <(DifficultyLevel.getPaddleHeight()) )) {
stopBall();
paddle = true;
}
Expand All @@ -153,15 +153,15 @@ public void releaseBallFromPaddle(KeyEvent evt, double distance)
{
//attached = false;
setAttached(false);
if(evt.getKeyCode() == KeyEvent.VK_A && ( (int)(distance+50) < DifficultyLevel.getPaddleHeight() ) ) {
if(evt.getKeyCode() == KeyEvent.VK_A && ( (int)(distance+35) < DifficultyLevel.getPaddleHeight() ) ) {
setYVelocity(p1.getYVelocity());
if(getSpeedX() < 0)
setXVelocity(getSpeedX() * -1);
else
setXVelocity(getSpeedX());
}

if(evt.getKeyCode() == KeyEvent.VK_LEFT && ( (int)(distance+40) < DifficultyLevel.getPaddleHeight() ) ) {
if(evt.getKeyCode() == KeyEvent.VK_LEFT && ( (int)(distance+45) < DifficultyLevel.getPaddleHeight() ) ) {
setYVelocity(p2.getYVelocity());
if(getSpeedX() > 0)
setXVelocity(getSpeedX() * -1);
Expand All @@ -175,7 +175,7 @@ public void releaseBallFromPaddle(KeyEvent evt, double distance)
* @param distance ArrayList of distances from balls
*/
public void keyPressed(KeyEvent evt, ArrayList<Double> distance){
if ( (evt.getKeyCode() == KeyEvent.VK_A) && ( distance.get(0) < DifficultyLevel.getPaddleHeight()) && (isAttached() == false)) {
if ( (evt.getKeyCode() == KeyEvent.VK_A) && ( (int)(distance.get(0)+35) < DifficultyLevel.getPaddleHeight()) && (isAttached() == false)) {
holdBallToPaddle(evt, distance.get(0));
}
if(paddle == false && isAttached() == true){
Expand All @@ -186,10 +186,13 @@ public void keyPressed(KeyEvent evt, ArrayList<Double> distance){
if( evt.getKeyCode() == KeyEvent.VK_S && distance.get(2) > 5){
setYVelocity(p1.getYVelocity());
}
}
}else{
setYVelocity(0);
}

}

if (evt.getKeyCode() == KeyEvent.VK_LEFT && distance.get(1)< DifficultyLevel.getPaddleHeight() && isAttached() == false) {
if (evt.getKeyCode() == KeyEvent.VK_LEFT && (int)(distance.get(1)+45)< DifficultyLevel.getPaddleHeight() && isAttached() == false) {
holdBallToPaddle(evt, distance.get(1));
}
if(paddle == true && isAttached() == true){
Expand All @@ -200,7 +203,9 @@ public void keyPressed(KeyEvent evt, ArrayList<Double> distance){
if( evt.getKeyCode() == KeyEvent.VK_DOWN && distance.get(3) > 5 ){
setYVelocity(p2.getYVelocity());
}
}
} else{
setYVelocity(0);
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/edu/ucsb/cs56/projects/games/pong/highscore/scores.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
57,V
50,Richard
32,ProfessorOak
14,
12,mee
9,Cloud Strife
9,Andrew YEAH
Expand All @@ -16,4 +17,4 @@
2,Caitsith
1,Victoria
0,sam
15,
261,

0 comments on commit 95efc66

Please sign in to comment.