1- <!-- <h1>Welcome!</h1>
2-
3- <section>
4- <h2>World 1</h2>
5- <a href="/game?stage=1">Stage 1</a>
6- <a href="/game?stage=2">Stage 2</a>
7- <a href="/game?stage=3">Stage 3</a>
8- <a href="/game?stage=4">Stage 4</a>
9- <a href="/game?stage=5">Stage 5</a>
10- <a href="/game?stage=6">Stage 6</a>
11- <a href="/game?stage=7">Stage 7</a>
12- <a href="/game?stage=8">Stage 8</a>
13- </section>
14-
15- <section>
16- <h2>World 3</h2>
17- <a href="/game?stage=3-1">Stage 1</a>
18- <a href="/game?stage=3-2">Stage 2</a>
19- <a href="/game?stage=3-3">Stage 3</a>
20- <a href="/game?stage=3-4">Stage 4</a>
21- </section>
22-
23- <section>
24- <h2>World 4</h2>
25- <a href="/game?stage=4-1">Stage 1</a>
26- <a href="/game?stage=4-2">Stage 2</a>
27- </section>
28-
29- <p>
30- <a href="/stage-select">Stage-Select</a>
31- </p> -->
32-
331<script lang =" ts" >
34- import { onDestroy } from " svelte" ;
2+ import { onDestroy , onMount } from " svelte" ;
3+ import " @/ui-components/menu/menu.css" ;
354
5+ onMount (() => {
6+ const userAgent = navigator .userAgent .toLowerCase ();
7+ if (
8+ userAgent .includes (" android" ) ||
9+ userAgent .match (/ iphone| ipad| ipod/ ) ||
10+ (userAgent .includes (" macintosh" ) && navigator .maxTouchPoints >= 1 ) /* recent iPad */
11+ ) {
12+ window .alert (" このゲームはPC用です。キーボードが接続されていない端末ではプレイできません。" );
13+ }
14+ });
3615onDestroy (() => {
3716 // document.body.style.backgroundColor = "black";
3817});
18+
19+ let btn1: HTMLElement ;
20+ let btn2: HTMLElement ;
21+ function handleKeyDown(e : KeyboardEvent ) {
22+ const buttons = [btn1 , btn2 ];
23+ const currentIndex = buttons .indexOf (document .activeElement as HTMLElement );
24+ if (e .key === " ArrowUp" ) {
25+ if (currentIndex > 0 ) {
26+ buttons [currentIndex - 1 ].focus ();
27+ } else {
28+ buttons [buttons .length - 1 ].focus ();
29+ }
30+ e .preventDefault ();
31+ } else if (e .key === " ArrowDown" ) {
32+ if (currentIndex < buttons .length - 1 ) {
33+ buttons [currentIndex + 1 ].focus ();
34+ } else {
35+ buttons [0 ].focus ();
36+ }
37+ e .preventDefault ();
38+ } else if (e .key === " " ) {
39+ (document .activeElement as HTMLElement )?.click ?.();
40+ e .preventDefault ();
41+ }
42+ }
43+ $effect (() => {
44+ document .addEventListener (" keydown" , handleKeyDown );
45+ return () => {
46+ document .removeEventListener (" keydown" , handleKeyDown );
47+ };
48+ });
3949 </script >
4050
4151<div id =" container" class =" fixed inset-0" >
42- <div class =" fixed inset-0 backdrop-blur-xs" >
43- <div class =" flex flex-col gap-5 mt-30 m-10 p-5 bg-yellow-400/85 rounded-lg" >
44- <h1 class =" text-center mt-6 mb-2" >Shortcut Game</h1 > <!--TODO: 題名-->
45- <a class =" btn modal-btn text-2xl" href =" /game?stage=1" > Start </a >
46- <a class =" btn modal-btn text-2xl" href =" /stage-select" > Stage Select </a >
52+ <div class =" fixed inset-0 backdrop-blur-xs flex flex-col justify-center" >
53+ <div class =" flex flex-col gap-5 mb-20 m-10 p-5 bg-yellow-400/85 rounded-lg" >
54+ <h1 class =" text-center mt-6 mb-2" >Shortcut Game</h1 >
55+ <!--TODO: 題名-->
56+ <a class ="btn modal-btn text-2xl" href ="/game?stage=1-1" bind:this ={btn1 } tabindex =" 1" > Start from 1-1 </a >
57+ <a class ="btn modal-btn text-2xl" href ="/stage-select" bind:this ={btn2 } tabindex =" 2" > Stage Select </a >
4758 <p class =" bg-white/90 p-2 rounded-lg" >
48- Move: ⇦ ⇨ or A D<br />
59+ Move: ⇦ ⇨ or A D<br />
4960 Jump: ⇧ or W or Space<br />
5061 Ability: Ctrl + ?
5162 </p >
@@ -56,10 +67,12 @@ onDestroy(() => {
5667<style >
5768 #container {
5869 background-color : black ;
59- background-image : url (' /assets/home.png' ), url (' /assets/home-block.png' );
70+ background-image : url (" /assets/home.png" ), url (" /assets/home-block.png" );
6071 background-size : 100% , 100% ;
6172 background-repeat : no-repeat , repeat-y ;
62- background-position : left top , left , top ;
63- backdrop-filter : blur (10px );
73+ background-position :
74+ left top ,
75+ left ,
76+ top ;
6477 }
6578 </style >
0 commit comments