Skip to content
This repository has been archived by the owner on Jun 6, 2022. It is now read-only.

Commit

Permalink
fix speed time increment
Browse files Browse the repository at this point in the history
  • Loading branch information
Renan committed Nov 7, 2018
1 parent 90de1ef commit 1b61cbb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 12 additions & 8 deletions lib/game/Game.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class TRexGame extends BaseGame{
TRexGameStatus status = TRexGameStatus.waiting;

double currentSpeed = GameConfig.speed;
double timePlaying = 0.0;

TRexGame({
Image spriteImage
Expand Down Expand Up @@ -54,18 +55,20 @@ class TRexGame extends BaseGame{
}

if(this.playing){
timePlaying += t;
horizon.updateWithSpeed(t, this.currentSpeed);
}

var obstacles = horizon.horizonLine.obstacleManager.components;
bool collision = obstacles.length > 0 && checkForCollision(obstacles.first, tRex);
if(!collision){
if (this.currentSpeed < GameConfig.maxSpeed) {
this.currentSpeed += GameConfig.acceleration;
var obstacles = horizon.horizonLine.obstacleManager.components;
bool collision = obstacles.length > 0 && checkForCollision(obstacles.first, tRex);
if(!collision){
if (this.currentSpeed < GameConfig.maxSpeed) {
this.currentSpeed += GameConfig.acceleration;
}
} else {
doGameOver();
}
} else {
doGameOver();
}

}

void startGame () {
Expand Down Expand Up @@ -93,6 +96,7 @@ class TRexGame extends BaseGame{
horizon.reset();
currentSpeed = GameConfig.speed;
gameOverPanel.visible = false;
timePlaying = 0.0;

}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/game/game_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ class GameConfig {
static int maxObstacleDuplication = 2;
static double maxSpeed = 13.0;
static double minJumpHeight = 35.0;
static double speed = 6.0;
static double speed = 6.5;
static double speedDropCoefficient = 3.0;
}

0 comments on commit 1b61cbb

Please sign in to comment.