Skip to content

Commit

Permalink
Added end screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Timic3 committed Mar 22, 2018
1 parent a4c866b commit afd5556
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { MatDialog } from '@angular/material';

import { HelloComponent } from './hello/hello.component';
import { LeaderboardComponent } from './leaderboard/leaderboard.component';
import { EndComponent } from './end/end.component';

import { AppConstants } from './app.constants';
import { AppStates } from './app.states';
Expand Down Expand Up @@ -110,6 +111,12 @@ export class AppComponent implements AfterContentInit {
}
}

// BAD AGAIN
if (AppStates.ENDED) {
AppStates.ENDED = false;
this.openEnd();
}

if (this.levelUp) {
this.levelUpSize += 0.03;
if (this.levelUpSize >= 1) {
Expand Down Expand Up @@ -208,6 +215,12 @@ export class AppComponent implements AfterContentInit {
});
}

openEnd() {
const dialog = this.dialog.open(EndComponent, {
width: '500px'
});
}

cameraShake() {
if (this.shakeTickStart === -1) {
return;
Expand Down
6 changes: 4 additions & 2 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ import {
import { AppComponent } from './app.component';
import { HelloComponent } from './hello/hello.component';
import { LeaderboardComponent } from './leaderboard/leaderboard.component';
import { EndComponent } from './end/end.component';


@NgModule({
declarations: [
AppComponent,
HelloComponent,
LeaderboardComponent
LeaderboardComponent,
EndComponent
],
imports: [
BrowserModule,
Expand All @@ -30,6 +32,6 @@ import { LeaderboardComponent } from './leaderboard/leaderboard.component';
],
providers: [],
bootstrap: [AppComponent],
entryComponents: [HelloComponent, LeaderboardComponent]
entryComponents: [HelloComponent, LeaderboardComponent, EndComponent]
})
export class AppModule { }
1 change: 1 addition & 0 deletions src/app/app.states.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { AppConstants } from './app.constants';

export class AppStates {
public static STARTED = false;
public static ENDED = false;
public static STAGE = 1;
public static CHANGING_STAGE = false;

Expand Down
2 changes: 2 additions & 0 deletions src/app/classes/Packet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { LeaderboardComponent } from '../leaderboard/leaderboard.component';
import { MatDialog } from '@angular/material';

import { AppConstants } from '../app.constants';
import { AppStates } from '../app.states';
Expand Down Expand Up @@ -284,6 +285,7 @@ export class Packet extends Drawable {
// Reset game
AppStates.STARTED = false;
LeaderboardComponent.saveScore(AppStates.STAGE);
AppStates.ENDED = true;
AppStates.STAGE = 1;
AppStates.WALLS_X = 3;
AppStates.WALLS_WIDTH = AppConstants.GAME_WIDTH / AppStates.WALLS_X;
Expand Down
11 changes: 11 additions & 0 deletions src/app/end/end.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<h1 mat-dialog-title>🖤 You've lost all your lives</h1>

<mat-dialog-content>
<h4>Your score was saved.</h4>
</mat-dialog-content>

<mat-dialog-actions align="end">
<button (click)="dialogRef.close()" color="primary" mat-raised-button>
Okay
</button>
</mat-dialog-actions>
Empty file added src/app/end/end.component.scss
Empty file.
13 changes: 13 additions & 0 deletions src/app/end/end.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Component } from '@angular/core';
import { MatDialogRef } from '@angular/material';

@Component({
selector: 'app-end',
templateUrl: './end.component.html',
styleUrls: ['./end.component.scss']
})
export class EndComponent {

constructor(public dialogRef: MatDialogRef<EndComponent>) { }

}

0 comments on commit afd5556

Please sign in to comment.