diff --git a/Game_Code/src/model/Player.java b/Game_Code/src/model/Player.java index 740c7ebefbd330b69fb18f2cb14f5b667e1443bf..95a7a6882092ff777572bdaba1ad6bf1c291f2dc 100644 --- a/Game_Code/src/model/Player.java +++ b/Game_Code/src/model/Player.java @@ -56,4 +56,8 @@ public class Player { if(score==NOLIFE){ return true;} else{ return false; } } + + public void resetScore(){ + score = LIFE; + } } diff --git a/Game_Code/src/startGame/GameController.java b/Game_Code/src/startGame/GameController.java index d36c0a9fa36b0b290bf95ce77610686d3986b5b1..e05f3b0fae55be45031f674957e60b64f8d14d74 100644 --- a/Game_Code/src/startGame/GameController.java +++ b/Game_Code/src/startGame/GameController.java @@ -388,13 +388,13 @@ public class GameController{ gameDisplay.setBottomScore(scoreBottom); ai.decrementLife(); - } else if(ballY+2.5*ballSize>frameHeight-inset-2*padHeight && velY > 0 && ballX + ballSize >= bottomPadX && ballX <= bottomPadX + padWidth){ + } else if(ballY+2.5*ballSize>frameHeight-inset-padHeight && velY > 0 && ballX + ballSize >= bottomPadX && ballX <= bottomPadX + padWidth){ /** * If the ball is touching the bottom paddle * - reverse the direction */ velY = -velY; - } else if(ballY<=inset+2*padHeight && velY < 0 && ballX + ballSize >= topPadX && ballX <= topPadX + padWidth){ + } else if(ballY<=inset+padHeight && velY < 0 && ballX + ballSize >= topPadX && ballX <= topPadX + padWidth){ /** * If the ball is touching the top paddle * - reverse the direction @@ -594,16 +594,12 @@ public class GameController{ endTime = System.currentTimeMillis(); timeElapsed = (endTime-startTime)/1000.0; - System.out.println(timeElapsed); +System.out.println(timeElapsed); } private void resetGame(){ - scoreTop = 0; - scoreBottom = 0; - - - - + player.resetScore(); + ai.resetScore(); } diff --git a/Game_Code/src/view/GameView.java b/Game_Code/src/view/GameView.java index f3d47aa38945f145aaefdc9a368e74452fc524d3..6381021662ffeee69463406b6f16322b6d28a506 100644 --- a/Game_Code/src/view/GameView.java +++ b/Game_Code/src/view/GameView.java @@ -96,6 +96,9 @@ public class GameView{ public void createGame(){ gameFrame = new JFrame("FaultInOurPong"); gameFrame.setContentPane(ponggame); + + + gameFrame.setSize(FRAMEWIDTH,FRAMEHEIGHT); gameFrame.setResizable(false); gameFrame.setLocationRelativeTo(null);