Skip to content

Commit a9cd158

Browse files
committed
More changes for force stop
1 parent b026faf commit a9cd158

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

core/src/com/group/golf/Physics/Physics.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,14 @@ protected boolean checkLowVelocity() {
120120
float[] slope = this.calculateSlope(new float[]{this.movingBall.getX(), this.movingBall.getY()});
121121
float vx = this.movingBall.getVelocityX();
122122
float vy = this.movingBall.getVelocityY();
123-
if ((vx < 0 && slope[0] > 0 && vx >= -errorBound) || (vx > 0 && slope[0] < 0 && vx <= errorBound)) {
123+
if (vx != 0 && ((vx < 0 && slope[0] >= 0 && vx >= -errorBound) ||
124+
(vx > 0 && slope[0] <= 0 && vx <= errorBound))) {
125+
// System.out.println("VelocityX reset!");
124126
this.movingBall.resetX();
125127
}
126-
if ((vy < 0 && slope[1] > 0 && vy >= -errorBound) || (vy > 0 && slope[1] < 0 && vy <= errorBound)) {
128+
if (vy != 0 && ((vy < 0 && slope[1] >= 0 && vy >= -errorBound) ||
129+
(vy > 0 && slope[1] <= 0 && vy <= errorBound))) {
130+
// System.out.println("VelocityY reset!");
127131
this.movingBall.resetY();
128132
}
129133
return !this.movingBall.isMoving();

core/src/com/group/golf/Physics/RK4.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class RK4 extends Physics {
1818
*/
1919
public RK4(Course course) {
2020
super(course);
21-
errorBound = 0.15f;
21+
errorBound = 0.2f;
2222
}
2323

2424
//method to be overwritten by each subclass

0 commit comments

Comments
 (0)