Skip to content

Commit f858794

Browse files
feat: refactor game UI styles for improved loading display and transitions
1 parent bf3afdf commit f858794

File tree

1 file changed

+56
-55
lines changed

1 file changed

+56
-55
lines changed

src/game.css

Lines changed: 56 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
@font-face {
2+
font-family: "Crash-a-Like";
3+
src: url("/crash-a-like.ttf") format("truetype");
4+
}
5+
16
.game-container {
27
position: fixed;
38
top: 0;
@@ -11,7 +16,7 @@
1116
height: 100%;
1217
}
1318

14-
.game-container > .loading-overlay {
19+
.game-container > .heads-up-display {
1520
position: absolute;
1621
top: 0;
1722
left: 0;
@@ -25,99 +30,95 @@
2530
gap: 20px;
2631
background-color: #6e4063;
2732
opacity: 1;
28-
transition: opacity 1s ease-in-out;
33+
backdrop-filter: blur(10px);
34+
transition: opacity 0.5s ease-in-out, background-color 2s ease-in-out;
35+
}
36+
37+
.game-container.is-loaded > .heads-up-display {
38+
background-color: #6e406383;
2939
}
3040

31-
.game-container > .loading-overlay.loaded {
41+
.game-container.is-started > .heads-up-display {
3242
opacity: 0;
3343
pointer-events: none;
3444
}
3545

36-
.game-container > .loading-overlay > .game-logo {
46+
.game-container > .heads-up-display > .game-logo,
47+
.game-container > .heads-up-display > .start-button {
3748
width: 80%;
3849
max-width: 300px;
50+
transition: opacity 0.3s ease-in-out, transform 0.1s ease-in-out;
3951
}
4052

41-
.game-container > .loading-overlay > .loading-indicator-bar {
42-
width: 80%;
43-
max-width: 200px;
44-
height: 20px;
45-
background-color: #ffffff73;
46-
border-radius: 10px;
47-
box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
48-
overflow: hidden;
53+
.game-container > .heads-up-display > .start-button {
54+
opacity: 0;
55+
pointer-events: none;
56+
cursor: pointer;
4957
}
5058

51-
.game-container
52-
> .loading-overlay
53-
> .loading-indicator-bar
54-
> .loading-indicator-fill {
55-
width: 0;
56-
height: 100%;
57-
background-image: linear-gradient(0deg, #ffa229, #ff6f61);
58-
transition: width 0.5s ease-in-out;
59+
.game-container > .heads-up-display > .start-button:hover {
60+
transform: scale(1.05);
5961
}
6062

61-
.game-container > .main-menu {
62-
position: absolute;
63-
top: 0;
64-
left: 0;
65-
width: 100%;
66-
height: 100%;
67-
display: flex;
68-
flex-direction: column;
69-
align-items: center;
70-
justify-content: center;
71-
gap: 20px;
72-
z-index: 90;
73-
background-color: rgba(110, 64, 99, 0.5);
74-
backdrop-filter: blur(5px);
75-
transition: opacity 0.5s ease-in-out;
63+
.game-container > .heads-up-display > .start-button:active {
64+
transform: scale(0.95);
7665
}
7766

78-
.game-container > .main-menu.started {
79-
opacity: 0;
80-
pointer-events: none;
67+
.game-container.is-started > .heads-up-display > .game-logo,
68+
.game-container.is-started > .heads-up-display > .start-button {
69+
transform: scale(0);
8170
}
8271

83-
.game-container > .main-menu > .game-logo,
84-
.game-container > .main-menu > .start-button {
72+
.game-container.is-loaded > .heads-up-display > .start-button {
73+
opacity: 1;
74+
pointer-events: auto;
75+
}
76+
77+
.game-container > .heads-up-display > .loading-bar {
8578
width: 80%;
86-
max-width: 300px;
79+
max-width: 200px;
80+
height: 20px;
81+
background-color: #ffffff73;
82+
border-radius: 10px;
83+
box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
84+
overflow: hidden;
85+
transition: opacity 0.2s ease-in-out;
8786
}
8887

89-
.game-container > .main-menu > .start-button {
90-
cursor: pointer;
91-
transition: transform 0.2s ease-in-out;
88+
.game-container.is-loaded > .heads-up-display > .loading-bar {
89+
opacity: 0;
9290
}
9391

94-
.game-container > .main-menu > .start-button:hover {
95-
transform: scale(1.05);
92+
.game-container > .heads-up-display > .loading-bar > .loading-fill {
93+
width: 0;
94+
height: 100%;
95+
background-image: linear-gradient(0deg, #ffa229, #ff6f61);
96+
transition: width 0.1s ease-in-out;
9697
}
9798

9899
.game-container > .score-display {
99100
position: absolute;
100101
top: 20px;
101102
left: 20px;
103+
right: 20px;
102104
z-index: 80;
103-
font-size: 60px;
104-
font-family: "Trebuchet MS", sans-serif;
105+
font-size: 10rem;
106+
font-family: "Crash-a-Like", sans-serif;
105107
font-weight: bold;
106-
background: linear-gradient(90deg, #ffa229, #ff6f61);
107-
background-clip: text;
108-
color: transparent;
109-
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
108+
color: #ffa229;
109+
text-shadow: 0 0 5px #ff6f61, 0 0 20px rgba(224, 210, 175, 0.3);
110+
text-align: center;
110111
}
111112

112113
.game-container > .fps-counter {
113114
position: absolute;
114-
top: 10px;
115+
bottom: 10px;
115116
left: 10px;
116117
right: 10px;
117118
z-index: 70;
118119
color: yellow;
119-
font-family: "Courier New", Courier, monospace;
120-
font-size: 14px;
120+
font-family: monospace;
121+
font-size: 1rem;
121122
text-align: center;
122123
pointer-events: none;
123124
}

0 commit comments

Comments
 (0)