Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FaultInOurPong
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Group3
FaultInOurPong
Commits
f24706da
Commit
f24706da
authored
8 years ago
by
Jie Luo
Browse files
Options
Downloads
Patches
Plain Diff
bug fixed for the ball not hitting the paddles
parent
548e8beb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Game_Code/src/model/Player.java
+4
-0
4 additions, 0 deletions
Game_Code/src/model/Player.java
Game_Code/src/startGame/GameController.java
+5
-9
5 additions, 9 deletions
Game_Code/src/startGame/GameController.java
Game_Code/src/view/GameView.java
+3
-0
3 additions, 0 deletions
Game_Code/src/view/GameView.java
with
12 additions
and
9 deletions
Game_Code/src/model/Player.java
+
4
−
0
View file @
f24706da
...
...
@@ -56,4 +56,8 @@ public class Player {
if
(
score
==
NOLIFE
){
return
true
;}
else
{
return
false
;
}
}
public
void
resetScore
(){
score
=
LIFE
;
}
}
This diff is collapsed.
Click to expand it.
Game_Code/src/startGame/GameController.java
+
5
−
9
View file @
f24706da
...
...
@@ -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
();
}
...
...
This diff is collapsed.
Click to expand it.
Game_Code/src/view/GameView.java
+
3
−
0
View file @
f24706da
...
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment