Skip to content

Instantly share code, notes, and snippets.

@renancaraujo
Last active November 7, 2018 00:08
Show Gist options
  • Save renancaraujo/517566f0d4307648b4a24365b631590c to your computer and use it in GitHub Desktop.
Save renancaraujo/517566f0d4307648b4a24365b631590c to your computer and use it in GitHub Desktop.
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