Skip to content

Commit 26fd628

Browse files
authored
impr: Add lose state to suika game and do a small refactor (#2350)
1 parent d6d0f63 commit 26fd628

5 files changed

Lines changed: 436 additions & 158 deletions

File tree

apps/typegpu-docs/src/examples/rendering/suika-sdf/constants.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ export const WALL_DEFS = [
99
{ cx: 0.5, cy: 0, hw: 0.05, hh: 0.55 },
1010
{ cx: -0.5, cy: 0, hw: 0.05, hh: 0.55 },
1111
];
12+
export const PHYSICS_WALL_DEFS = [
13+
{ cx: 0, cy: -0.5, hw: 0.5, hh: 0.05 },
14+
{ cx: 0.5, cy: 1.75, hw: 0.05, hh: 2.8 },
15+
{ cx: -0.5, cy: 1.75, hw: 0.05, hh: 2.8 },
16+
];
1217

1318
export const SCENE_SCALE = 0.75;
1419
export const WALL_COLOR = d.vec3f(0.55, 0.5, 0.45);
@@ -18,6 +23,14 @@ export const GHOST_ALPHA = 0.45;
1823
export const SMOOTH_MIN_K = 16.0;
1924
export const SHARP_FACTOR = 2.4;
2025
export const SPEED_BLEND_MAX = 0.5;
26+
export const PULL_ACTIVATION_FACTOR = 2.2;
27+
export const PULL_FORCE = 0.0015;
28+
export const LOSE_LINE_Y = 0.452;
29+
export const LOSE_TIMEOUT_MS = 8_000;
30+
export const WARNING_FLASH_SPEED = 0.01;
31+
export const ESCAPE_X = 0.72;
32+
export const ESCAPE_BOTTOM_Y = -0.85;
33+
export const LOSE_LINE_HALF_THICKNESS = 0.005;
2134

2235
export const MERGE_SCORES = Array.from({ length: LEVEL_COUNT }, (_, n) => ((n + 1) * (n + 2)) / 2);
2336

apps/typegpu-docs/src/examples/rendering/suika-sdf/index.html

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,76 @@
4444
#attribution a:hover {
4545
text-decoration: underline;
4646
}
47+
48+
#lose-screen {
49+
position: absolute;
50+
inset: 0;
51+
z-index: 4;
52+
display: grid;
53+
place-items: center;
54+
background: rgba(38, 14, 14, 0.55);
55+
backdrop-filter: blur(6px);
56+
}
57+
58+
#lose-screen[hidden] {
59+
display: none;
60+
}
61+
62+
#lose-card {
63+
min-width: 15rem;
64+
padding: 1.25rem 1.5rem;
65+
border-radius: 1rem;
66+
background: rgba(255, 247, 240, 0.94);
67+
box-shadow:
68+
0 1rem 2.5rem rgba(0, 0, 0, 0.3),
69+
inset 0 0 0 1px rgba(255, 255, 255, 0.65);
70+
text-align: center;
71+
color: #4d2216;
72+
font-family: 'Fredoka One', cursive;
73+
}
74+
75+
#lose-card h2 {
76+
margin: 0 0 0.625rem;
77+
font-size: 2rem;
78+
color: #c63d2f;
79+
}
80+
81+
#lose-score {
82+
margin-bottom: 1rem;
83+
font-size: 1.1rem;
84+
}
85+
86+
#reset-button {
87+
border: 0;
88+
border-radius: 999px;
89+
padding: 0.65rem 1.2rem;
90+
background: linear-gradient(180deg, #ffb45b, #ef7d32);
91+
color: white;
92+
font: inherit;
93+
cursor: pointer;
94+
box-shadow: 0 0.35rem 0 rgba(168, 78, 26, 0.9);
95+
}
96+
97+
#reset-button:hover {
98+
filter: brightness(1.05);
99+
}
100+
101+
#reset-button:active {
102+
transform: translateY(0.15rem);
103+
box-shadow: 0 0.2rem 0 rgba(168, 78, 26, 0.9);
104+
}
47105
</style>
48106

49107
<div id="score">0</div>
50108

109+
<div id="lose-screen" hidden>
110+
<div id="lose-card">
111+
<h2>Game Over</h2>
112+
<div id="lose-score">Score: <span id="final-score">0</span></div>
113+
<button id="reset-button" type="button">Reset</button>
114+
</div>
115+
</div>
116+
51117
<div id="attribution">
52118
Assets by
53119
<a href="https://apps2amigos.itch.io/fruit-game-free-asset-pack" target="_blank">Apps2Amigos</a

0 commit comments

Comments
 (0)