Skip to content

Commit

Permalink
Add welcome screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 committed May 5, 2017
1 parent 5412ac4 commit 39ab9d2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/ui/components/glimmeroids-app/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const KEY = {
const INITIAL_ASTEROID_COUNT = 3;

enum GameState {
Running = 1,
Welcome = 0,
Running,
GameOver,
}

Expand Down Expand Up @@ -76,7 +77,7 @@ export default class Glimmeroids extends Component {
asteroidCount: INITIAL_ASTEROID_COUNT,
currentScore: 0,
topScore: localStorage.topscore || 0,
gameState: GameState.Running,
gameState: GameState.Welcome,
};
this.ship = [];
this.asteroids = [];
Expand Down Expand Up @@ -145,7 +146,6 @@ export default class Glimmeroids extends Component {
...this.state,
context
};
this.startGame();
requestAnimationFrame(() => this.update());
}

Expand Down
15 changes: 10 additions & 5 deletions src/ui/components/glimmeroids-app/template.hbs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<div>
{{#if (eq state.gameState GameState.GameOver)}}
<div class="endgame">
<p>Game over, man!</p>
<p>{{gameOverMessage}}</p>
{{#if (not (eq state.gameState GameState.Running))}}
<div class="message">
<p>Glimmeroids</p>

{{#if (eq state.gameState GameState.GameOver)}}
<p>Game over, man!</p>
<p>{{gameOverMessage}}</p>
{{/if}}

<button onclick={{action startGame}}>
try again?
{{if (eq state.gameState GameState.GameOver) "try again?" "start the game"}}
</button>
</div>
{{/if}}
Expand Down
3 changes: 3 additions & 0 deletions src/ui/components/if/helper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function _if([test, truthy, falsy]: any[]) {
return test ? truthy : falsy;
}
3 changes: 3 additions & 0 deletions src/ui/components/not/helper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function not([value]: any[]) {
return !value;
}
2 changes: 1 addition & 1 deletion src/ui/styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ canvas {
text-align: center;
line-height: 1.6;
}
.endgame{
.message{
position: absolute;
top: 50%;
left: 50%;
Expand Down

0 comments on commit 39ab9d2

Please sign in to comment.