Skip to content

Commit

Permalink
fixed placing
Browse files Browse the repository at this point in the history
  • Loading branch information
wpw503 committed Feb 7, 2021
1 parent e28af67 commit 76f7f51
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
9 changes: 4 additions & 5 deletions core/src/main/java/com/dragonboatrace/DragonBoatRace.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public class DragonBoatRace extends Game {
protected int round = 1;

/**
* A list of best times for all boats.
* A list of total times for all boats.
*/
protected ArrayList<Float> totalTimes = new ArrayList<>();

/**
* The players best time.
* The players total time.
*/
protected float playerTotalTime = 0;

Expand Down Expand Up @@ -74,16 +74,15 @@ public void upRound() {
}

public void setTimeAt(int i, float t) {
if (t < this.totalTimes.get(i))
this.totalTimes.set(i, t);
this.totalTimes.set(i, this.totalTimes.get(i) + t);
}

public float getPlayerTotalTime() {
return this.playerTotalTime;
}

public void setPlayerTotalTime(float t) {
if (t < playerTotalTime) this.playerTotalTime = t;
this.playerTotalTime += t;
}

public ArrayList<Float> getTotalTimes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ public PlayerBoat(BoatType boat, Lane lane, String name) {
public void update(float deltaTime) {
/* Allow the player to move if there wasn't a recent collision */
if (!recentCollision) {
if ((Gdx.input.isKeyPressed(Input.Keys.LEFT) || Gdx.input.isKeyPressed(Input.Keys.A)) && this.position.x > this.lane.getHitbox().getX()) {
if ((Gdx.input.isKeyPressed(Input.Keys.LEFT) || Gdx.input.isKeyPressed(Input.Keys.A)) && this.position.x > this.lane.getHitbox().getX() - 50) {
this.velocity.set(-this.speed, this.velocity.y);
}

if ((Gdx.input.isKeyPressed(Input.Keys.RIGHT) || Gdx.input.isKeyPressed(Input.Keys.D)) && (this.position.x + this.type.getWidth()) < this.lane.getHitbox().getWidth() + this.lane.getHitbox().getX()) {
if ((Gdx.input.isKeyPressed(Input.Keys.RIGHT) || Gdx.input.isKeyPressed(Input.Keys.D)) && (this.position.x + this.type.getWidth()) < 150 + this.lane.getHitbox().getWidth() + this.lane.getHitbox().getX()) {
this.velocity.set(this.speed, this.velocity.y);
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/com/dragonboatrace/tools/Race.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public void getLeaderBoard(DragonBoatRace game) {
break;
default:
if (game.getRound() != 4)
reason.append(times.indexOf(time)).append(1).append("th: ").append(boatN.getName()).append("\n");
reason.append(times.indexOf(time)+1).append("th: ").append(boatN.getName()).append("\n");
}
}
}
Expand Down

0 comments on commit 76f7f51

Please sign in to comment.