Skip to content

Commit c9ddc3a

Browse files
committed
Add logo animation
1 parent 7bd1801 commit c9ddc3a

File tree

5 files changed

+108
-0
lines changed

5 files changed

+108
-0
lines changed

src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { StartLineComponent } from './components/start-line/start-line.component
1818
import { AkitaNgDevtools } from '@datorama/akita-ngdevtools';
1919
import { environment } from '../environments/environment';
2020
import { TileComponent } from './components/tile/tile.component';
21+
import { LogoComponent } from './components/logo/logo.component';
2122

2223
@NgModule({
2324
declarations: [
@@ -36,6 +37,7 @@ import { TileComponent } from './components/tile/tile.component';
3637
LevelComponent,
3738
StartLineComponent,
3839
TileComponent,
40+
LogoComponent,
3941
],
4042
imports: [BrowserModule, environment.production ? [] : AkitaNgDevtools.forRoot()],
4143
providers: [],
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<div class="logo">
2+
<div [ngClass]="['bg dragon', className]"></div>
3+
<p>Press Space to start</p>
4+
</div>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
.logo {
2+
width: 224px;
3+
height: 200px;
4+
position: absolute;
5+
top: 100px;
6+
left: 12px;
7+
text-align: center;
8+
overflow: hidden;
9+
10+
p {
11+
position: absolute;
12+
width: 100%;
13+
line-height: 1.4;
14+
top: 100px;
15+
left: 0;
16+
font-family: initial;
17+
letter-spacing: 6px;
18+
text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.35);
19+
}
20+
21+
.dragon {
22+
width: 80px;
23+
height: 86px;
24+
margin: 0 auto;
25+
background-position: 0 -100px;
26+
&.r1,
27+
&.l1 {
28+
background-position: 0 -100px;
29+
}
30+
&.r2,
31+
&.l2 {
32+
background-position: -100px -100px;
33+
}
34+
&.r3,
35+
&.l3 {
36+
background-position: -200px -100px;
37+
}
38+
&.r4,
39+
&.l4 {
40+
background-position: -300px -100px;
41+
}
42+
&.l1,
43+
&.l2,
44+
&.l3,
45+
&.l4 {
46+
transform: scale(-1, 1);
47+
-webkit-transform: scale(-1, 1);
48+
-ms-transform: scale(-1, 1);
49+
-moz-transform: scale(-1, 1);
50+
-o-transform: scale(-1, 1);
51+
}
52+
}
53+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import { Observable, timer } from 'rxjs';
3+
import { finalize, map, startWith, takeWhile, tap } from 'rxjs/operators';
4+
5+
@Component({
6+
selector: 't-logo',
7+
templateUrl: './logo.component.html',
8+
styleUrls: ['./logo.component.scss']
9+
})
10+
export class LogoComponent implements OnInit {
11+
className: string = '';
12+
constructor() {}
13+
14+
ngOnInit(): void {
15+
this.run().subscribe();
16+
}
17+
18+
eyes() {
19+
return timer(0, 150).pipe(
20+
startWith(0),
21+
map((x) => x + 1),
22+
takeWhile((x) => x < 6),
23+
tap((x) => {
24+
let state = x % 2 === 0 ? 1 : 2;
25+
this.className = `l${state}`;
26+
})
27+
);
28+
}
29+
30+
run(): Observable<number> {
31+
let side = 'r';
32+
return timer(0, 100).pipe(
33+
startWith(0),
34+
map((x) => x + 1),
35+
takeWhile((x) => x <= 40),
36+
tap((x) => {
37+
if (x === 10 || x === 20 || x === 30) {
38+
side = side === 'r' ? 'l' : 'r';
39+
}
40+
let state = x % 2 === 0 ? 3 : 4;
41+
this.className = `${side}${state}`;
42+
}),
43+
finalize(() => {
44+
this.className = `${side}1`;
45+
})
46+
);
47+
}
48+
}

src/app/containers/angular-tetris/angular-tetris.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<div class="screen">
55
<div class="panel">
66
<t-matrix></t-matrix>
7+
<t-logo></t-logo>
78
<div class="state">
89
<t-point></t-point>
910
<t-start-line></t-start-line>

0 commit comments

Comments
 (0)