From 1b61cbb23b9d7737e99ac8d496a9813fef9ed31c Mon Sep 17 00:00:00 2001 From: Renan Date: Wed, 7 Nov 2018 00:22:44 -0200 Subject: [PATCH] fix speed time increment --- lib/game/Game.dart | 20 ++++++++++++-------- lib/game/game_config.dart | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/game/Game.dart b/lib/game/Game.dart index 4973d7f..22c40e3 100644 --- a/lib/game/Game.dart +++ b/lib/game/Game.dart @@ -18,6 +18,7 @@ class TRexGame extends BaseGame{ TRexGameStatus status = TRexGameStatus.waiting; double currentSpeed = GameConfig.speed; + double timePlaying = 0.0; TRexGame({ Image spriteImage @@ -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 () { @@ -93,6 +96,7 @@ class TRexGame extends BaseGame{ horizon.reset(); currentSpeed = GameConfig.speed; gameOverPanel.visible = false; + timePlaying = 0.0; } } diff --git a/lib/game/game_config.dart b/lib/game/game_config.dart index 1a746dd..51457be 100644 --- a/lib/game/game_config.dart +++ b/lib/game/game_config.dart @@ -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; } \ No newline at end of file