Last active
November 7, 2018 00:08
-
-
Save renancaraujo/517566f0d4307648b4a24365b631590c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TRexGame extends BaseGame{ | |
TRex tRex; | |
Horizon horizon; | |
GameOverPanel gameOverPanel; | |
TRexGameStatus status = TRexGameStatus.waiting; | |
double currentSpeed = GameConfig.speed; | |
TRexGame({ | |
Image spriteImage | |
}) { | |
tRex = new TRex(spriteImage); | |
horizon = new Horizon(spriteImage); | |
gameOverPanel = new GameOverPanel(spriteImage); | |
this..add(horizon)..add(tRex)..add(gameOverPanel); | |
} | |
void onTap() { | |
if(gameOver){ | |
restart(); | |
return; | |
} | |
tRex.startJump(this.currentSpeed); | |
} | |
@override | |
void update(double t) { | |
tRex.update(t); | |
horizon.updateWithSpeed(0.0, this.currentSpeed); | |
if(gameOver) return; | |
if(tRex.playingIntro && tRex.x >= TRexConfig.startXPos ) { | |
startGame(); | |
} else if (tRex.playingIntro) { | |
horizon.updateWithSpeed(0.0, this.currentSpeed); | |
} | |
} | |
/* .... continues .... */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment