Skip to content

Commit af59f60

Browse files
authored
Fix bugs in 한글 HERO (#112)
* Break down glommed characters * Add final score * Fix mobile fallback font
1 parent 112bca6 commit af59f60

1 file changed

Lines changed: 36 additions & 5 deletions

File tree

src/pages/games/hangul-hero.astro

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,15 +1000,15 @@ import BaseLayout from "../../layouts/base.astro";
10001000
}
10011001

10021002
.mobile-message h2 {
1003-
font-family: "Press Start 2P", cursive;
1003+
font-family: "Press Start 2P", "Courier New", Courier, monospace;
10041004
color: #ff3366;
10051005
font-size: 1.2rem;
10061006
margin-bottom: 1rem;
10071007
text-shadow: 2px 2px 0 #000;
10081008
}
10091009

10101010
.mobile-message p {
1011-
font-family: "Press Start 2P", cursive;
1011+
font-family: "Press Start 2P", "Courier New", Courier, monospace;
10121012
color: #fff;
10131013
font-size: 0.8rem;
10141014
line-height: 1.5;
@@ -1762,9 +1762,16 @@ import BaseLayout from "../../layouts/base.astro";
17621762
input.addEventListener("input", (e) => {
17631763
if (!this.isPlaying || this.isPaused || !this.isPowered) return; // Don't process input when powered off or paused
17641764

1765-
const char = (e.target as HTMLInputElement).value;
1766-
if (char) {
1767-
this.handleKeyPress(char);
1765+
const inputValue = (e.target as HTMLInputElement).value;
1766+
if (inputValue) {
1767+
// Decompose the input value into its constituent parts
1768+
inputValue
1769+
.split("")
1770+
.filter(Boolean)
1771+
.flatMap((char) => char.normalize("NFD").split(""))
1772+
.forEach((char) => {
1773+
this.handleKeyPress(char);
1774+
});
17681775
// Clear the input for the next character
17691776
(e.target as HTMLInputElement).value = "";
17701777
}
@@ -2501,6 +2508,30 @@ import BaseLayout from "../../layouts/base.astro";
25012508
this.p.fill(255, 255, 255, this.startTextOpacity * 255);
25022509
this.p.textSize(40);
25032510
this.p.text(titleText, this.p.width / 2, this.p.height / 2 - 20);
2511+
2512+
// Draw final score
2513+
this.p.textSize(24);
2514+
this.p.textAlign(this.p.CENTER, this.p.CENTER);
2515+
2516+
// Score glow effect
2517+
const scoreGlowColor = this.p.color("#00ff00");
2518+
scoreGlowColor.setAlpha(this.startTextOpacity * 100);
2519+
this.p.fill(scoreGlowColor);
2520+
this.p.textSize(26);
2521+
this.p.text(
2522+
`FINAL SCORE: ${this.score}`,
2523+
this.p.width / 2,
2524+
this.p.height / 2 + 40
2525+
);
2526+
2527+
// Main score text
2528+
this.p.fill(255, 255, 255, this.startTextOpacity * 255);
2529+
this.p.textSize(24);
2530+
this.p.text(
2531+
`FINAL SCORE: ${this.score}`,
2532+
this.p.width / 2,
2533+
this.p.height / 2 + 40
2534+
);
25042535
} else {
25052536
// 한글 HERO title with wave animation
25062537
this.p.textSize(60);

0 commit comments

Comments
 (0)