gaesup-world 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/README.md +51 -0
  2. package/index.html +13 -0
  3. package/package.json +82 -0
  4. package/src/gaesup/animation/actions.ts +123 -0
  5. package/src/gaesup/camera/cameraCollisionDetecter.tsx +53 -0
  6. package/src/gaesup/camera/control/map.ts +10 -0
  7. package/src/gaesup/camera/control/normal copy.ts +19 -0
  8. package/src/gaesup/camera/control/normal.ts +15 -0
  9. package/src/gaesup/camera/control/orbit.ts +31 -0
  10. package/src/gaesup/camera/index.tsx +102 -0
  11. package/src/gaesup/camera/type.ts +17 -0
  12. package/src/gaesup/component/Airplane.tsx +46 -0
  13. package/src/gaesup/component/Character.tsx +48 -0
  14. package/src/gaesup/component/Vehicle.tsx +40 -0
  15. package/src/gaesup/component/gltf/AirplaneGltf.tsx +31 -0
  16. package/src/gaesup/component/gltf/CharacterGltf.tsx +81 -0
  17. package/src/gaesup/component/gltf/VehicleGltf.tsx +31 -0
  18. package/src/gaesup/component/gltf/WheelJoint.tsx +39 -0
  19. package/src/gaesup/component/gltf/type.ts +6 -0
  20. package/src/gaesup/component/ref/airplane.tsx +83 -0
  21. package/src/gaesup/component/ref/character.tsx +132 -0
  22. package/src/gaesup/component/ref/vehicle.tsx +145 -0
  23. package/src/gaesup/controller/index.tsx +103 -0
  24. package/src/gaesup/controller/type.ts +139 -0
  25. package/src/gaesup/gaesupProps/index.tsx +66 -0
  26. package/src/gaesup/initial/callback/index.ts +73 -0
  27. package/src/gaesup/initial/callback/type.ts +45 -0
  28. package/src/gaesup/initial/controller/index.ts +143 -0
  29. package/src/gaesup/initial/controller/initDebug.ts +102 -0
  30. package/src/gaesup/initial/gaesupWorld/collider/airplane.ts +26 -0
  31. package/src/gaesup/initial/gaesupWorld/collider/character.ts +32 -0
  32. package/src/gaesup/initial/gaesupWorld/collider/gltf.ts +91 -0
  33. package/src/gaesup/initial/gaesupWorld/collider/index.ts +26 -0
  34. package/src/gaesup/initial/gaesupWorld/collider/vehicle.ts +43 -0
  35. package/src/gaesup/initial/gaesupWorld/index.ts +82 -0
  36. package/src/gaesup/initial/gaesupWorld/type.ts +37 -0
  37. package/src/gaesup/physics/airplane/currentSetting.ts +20 -0
  38. package/src/gaesup/physics/airplane/damping.ts +8 -0
  39. package/src/gaesup/physics/airplane/direction.ts +70 -0
  40. package/src/gaesup/physics/airplane/gravity.ts +11 -0
  41. package/src/gaesup/physics/airplane/impulse.ts +22 -0
  42. package/src/gaesup/physics/airplane/index.tsx +16 -0
  43. package/src/gaesup/physics/airplane/turn.ts +12 -0
  44. package/src/gaesup/physics/airplane copy/currentSetting.ts +20 -0
  45. package/src/gaesup/physics/airplane copy/direction.ts +52 -0
  46. package/src/gaesup/physics/airplane copy/gravity.ts +6 -0
  47. package/src/gaesup/physics/airplane copy/impulse.ts +28 -0
  48. package/src/gaesup/physics/airplane copy/index.tsx +14 -0
  49. package/src/gaesup/physics/airplane copy/turn.ts +9 -0
  50. package/src/gaesup/physics/character/accelaration.ts +14 -0
  51. package/src/gaesup/physics/character/currentSetting.ts +20 -0
  52. package/src/gaesup/physics/character/damping.ts +6 -0
  53. package/src/gaesup/physics/character/direction.ts +104 -0
  54. package/src/gaesup/physics/character/impulse.ts +24 -0
  55. package/src/gaesup/physics/character/index.tsx +20 -0
  56. package/src/gaesup/physics/character/jump.ts +21 -0
  57. package/src/gaesup/physics/character/stabilizing.ts +6 -0
  58. package/src/gaesup/physics/character/turn.ts +17 -0
  59. package/src/gaesup/physics/check/ground.ts +19 -0
  60. package/src/gaesup/physics/check/index.ts +12 -0
  61. package/src/gaesup/physics/check/moving.ts +21 -0
  62. package/src/gaesup/physics/check/rotate.ts +13 -0
  63. package/src/gaesup/physics/check/slope.ts +50 -0
  64. package/src/gaesup/physics/index.ts +50 -0
  65. package/src/gaesup/physics/type.ts +35 -0
  66. package/src/gaesup/physics/vehicle/currentSetting.ts +20 -0
  67. package/src/gaesup/physics/vehicle/damping.ts +8 -0
  68. package/src/gaesup/physics/vehicle/direction.ts +27 -0
  69. package/src/gaesup/physics/vehicle/impulse.ts +22 -0
  70. package/src/gaesup/physics/vehicle/index.tsx +14 -0
  71. package/src/gaesup/physics/vehicle/turn.ts +11 -0
  72. package/src/gaesup/stores/active/index.ts +19 -0
  73. package/src/gaesup/stores/active/type.ts +16 -0
  74. package/src/gaesup/stores/airplane/index.ts +6 -0
  75. package/src/gaesup/stores/airplane/type.ts +4 -0
  76. package/src/gaesup/stores/animation/index.ts +18 -0
  77. package/src/gaesup/stores/animation/type.ts +9 -0
  78. package/src/gaesup/stores/collider/index.ts +55 -0
  79. package/src/gaesup/stores/context/controller/index.ts +36 -0
  80. package/src/gaesup/stores/context/controller/reducer.ts +18 -0
  81. package/src/gaesup/stores/context/controller/type.ts +38 -0
  82. package/src/gaesup/stores/context/gaesupworld/index.ts +11 -0
  83. package/src/gaesup/stores/context/gaesupworld/reducer.ts +21 -0
  84. package/src/gaesup/stores/context/gaesupworld/type.ts +66 -0
  85. package/src/gaesup/stores/control/index.ts +33 -0
  86. package/src/gaesup/stores/control/type.ts +11 -0
  87. package/src/gaesup/stores/joystick/index.ts +72 -0
  88. package/src/gaesup/stores/joystick/type.ts +23 -0
  89. package/src/gaesup/stores/minimap/index.ts +5 -0
  90. package/src/gaesup/stores/minimap/type.ts +22 -0
  91. package/src/gaesup/stores/point/type.ts +6 -0
  92. package/src/gaesup/stores/states/index.tsx +10 -0
  93. package/src/gaesup/stores/states/type.ts +10 -0
  94. package/src/gaesup/stores/url/index.ts +6 -0
  95. package/src/gaesup/stores/url/type.ts +6 -0
  96. package/src/gaesup/styles.css.ts +26 -0
  97. package/src/gaesup/tools/gameboy/GameBoyButton.tsx +38 -0
  98. package/src/gaesup/tools/gameboy/index.tsx +36 -0
  99. package/src/gaesup/tools/gameboy/style.css.ts +78 -0
  100. package/src/gaesup/tools/gamepad/GamePadButton.tsx +31 -0
  101. package/src/gaesup/tools/gamepad/index.tsx +55 -0
  102. package/src/gaesup/tools/gamepad/style.css.ts +16 -0
  103. package/src/gaesup/tools/index.tsx +61 -0
  104. package/src/gaesup/tools/joystick/index.tsx +145 -0
  105. package/src/gaesup/tools/joystick/style.css.ts +40 -0
  106. package/src/gaesup/tools/jumpPoint/index.tsx +27 -0
  107. package/src/gaesup/tools/jumpPoint/style.css.ts +33 -0
  108. package/src/gaesup/tools/keyBoardToolTip/constant.ts +144 -0
  109. package/src/gaesup/tools/keyBoardToolTip/index.tsx +85 -0
  110. package/src/gaesup/tools/keyBoardToolTip/style.css.ts +49 -0
  111. package/src/gaesup/tools/minimap/index.tsx +47 -0
  112. package/src/gaesup/tools/minimap/style.css.ts +144 -0
  113. package/src/gaesup/tools/style.css.ts +34 -0
  114. package/src/gaesup/utils/constant.ts +1 -0
  115. package/src/gaesup/utils/ray.ts +23 -0
  116. package/src/gaesup/utils/ref.ts +17 -0
  117. package/src/gaesup/utils/vector.ts +40 -0
  118. package/src/gaesup/world/index.tsx +17 -0
  119. package/src/gaesup/world/type.ts +10 -0
  120. package/src/styles/constants/boxshadow.css.ts +499 -0
  121. package/src/styles/constants/constant.css.ts +81 -0
  122. package/src/styles/constants/direction.css.ts +168 -0
  123. package/src/styles/constants/flex.css.ts +68 -0
  124. package/src/styles/constants/gradient.css.ts +10 -0
  125. package/src/styles/constants/grid.css.ts +37 -0
  126. package/src/styles/constants/palette.css.ts +324 -0
  127. package/src/styles/constants/translate.css.ts +129 -0
  128. package/src/styles/global.css.ts +91 -0
  129. package/src/styles/recipe/base.css.ts +31 -0
  130. package/src/styles/recipe/button.css.ts +109 -0
  131. package/src/styles/recipe/index.css.ts +134 -0
  132. package/src/styles/recipe/input.css.ts +33 -0
  133. package/src/styles/sprinkles/color.css.ts +62 -0
  134. package/src/styles/sprinkles/direction.css.ts +26 -0
  135. package/src/styles/sprinkles/display.css.ts +25 -0
  136. package/src/styles/sprinkles/fontSize.css.ts +25 -0
  137. package/src/styles/sprinkles/grid.css.ts +25 -0
  138. package/src/styles/sprinkles/index.css.ts +22 -0
  139. package/src/styles/sprinkles/margin.css.ts +30 -0
  140. package/src/styles/sprinkles/padding.css.ts +30 -0
  141. package/src/styles/sprinkles/position.css.ts +14 -0
  142. package/src/styles/sprinkles/size.css.ts +23 -0
  143. package/src/styles/theme.css.ts +98 -0
  144. package/tsconfig.json +27 -0
  145. package/tsconfig.node.json +10 -0
  146. package/vite.config.ts +9 -0
@@ -0,0 +1,36 @@
1
+ import { createContext } from "react";
2
+ import { V3 } from "../../../utils/vector";
3
+ import { airplaneDefault } from "../../airplane";
4
+ import { dispatchType } from "../gaesupworld/type";
5
+ import {
6
+ gaesupControllerType,
7
+ orthographicCameraType,
8
+ perspectiveCameraType,
9
+ } from "./type";
10
+
11
+ export const gaesupControllerDefault = {
12
+ cameraMode: {
13
+ cameraType: "perspective" as "perspective",
14
+ controlType: "normal" as "normal",
15
+ } as perspectiveCameraType | orthographicCameraType,
16
+ cameraOption: {
17
+ offset: V3(-10, -10, -10),
18
+ },
19
+ perspectiveCamera: {
20
+ isFront: true,
21
+ XZDistance: 8,
22
+ YDistance: 1,
23
+ },
24
+ orthographicCamera: {
25
+ zoom: 1,
26
+ near: 0.1,
27
+ far: 1000,
28
+ },
29
+ airplane: { ...airplaneDefault },
30
+ };
31
+
32
+ export const GaesupControllerContext = createContext<gaesupControllerType>({
33
+ ...gaesupControllerDefault,
34
+ });
35
+ export const GaesupControllerDispatchContext =
36
+ createContext<dispatchType<gaesupControllerType>>(null);
@@ -0,0 +1,18 @@
1
+ import { gaesupControllerType } from "./type";
2
+
3
+ export function gaesupControllerReducer(
4
+ props: gaesupControllerType,
5
+ action: {
6
+ type: string;
7
+ payload?: gaesupControllerType;
8
+ }
9
+ ) {
10
+ switch (action.type) {
11
+ case "init": {
12
+ return { ...props };
13
+ }
14
+ case "update": {
15
+ return { ...props, ...action.payload };
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,38 @@
1
+ import { OrthographicCameraProps } from "@react-three/fiber";
2
+ import { Dispatch } from "react";
3
+
4
+ export type perspectiveCameraType = {
5
+ cameraType?: "perspective";
6
+ controlType?: "orbit" | "normal";
7
+ };
8
+ export type orthographicCameraType = {
9
+ cameraType?: "orthographic";
10
+ controlType?: "orbit";
11
+ };
12
+
13
+ export type gaesupCameraPropType =
14
+ | perspectiveCameraType
15
+ | orthographicCameraType;
16
+
17
+ export type gaesupCameraOptionType = {
18
+ offset?: THREE.Vector3;
19
+ };
20
+
21
+ export type perspectiveCameraPropType = {
22
+ isFront: boolean;
23
+ XZDistance: number;
24
+ YDistance: number;
25
+ };
26
+
27
+ export type gaesupControllerType = {
28
+ cameraMode: gaesupCameraPropType;
29
+ cameraOption: gaesupCameraOptionType;
30
+ perspectiveCamera: perspectiveCameraPropType;
31
+ orthographicCamera: OrthographicCameraProps;
32
+ };
33
+
34
+ export type gaesupControllerPartialType = Partial<gaesupControllerType>;
35
+ export type gaesupDisptachType = Dispatch<{
36
+ type: string;
37
+ payload?: Partial<gaesupControllerType>;
38
+ }>;
@@ -0,0 +1,11 @@
1
+ import { createContext } from "react";
2
+ import { dispatchType, gaesupWorldPropType } from "./type";
3
+
4
+ export const modeDefault = {
5
+ type: "character",
6
+ controller: "keyboard",
7
+ };
8
+
9
+ export const GaesupWorldContext = createContext<gaesupWorldPropType>(null);
10
+ export const GaesupWorldDispatchContext =
11
+ createContext<dispatchType<gaesupWorldPropType>>(null);
@@ -0,0 +1,21 @@
1
+ import { gaesupWorldPartialPropType, gaesupWorldPropType } from "./type";
2
+
3
+ export function gaesupReducer(
4
+ props: gaesupWorldPropType,
5
+ action: {
6
+ type: string;
7
+ payload?: gaesupWorldPartialPropType;
8
+ }
9
+ ) {
10
+ switch (action.type) {
11
+ case "init": {
12
+ return { ...props };
13
+ }
14
+ case "update": {
15
+ return { ...props, ...action.payload };
16
+ }
17
+ default: {
18
+ throw Error("Unknown action: " + action.type);
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,66 @@
1
+ import { Dispatch } from "react";
2
+ import { GLTFResult } from "../../../component/gltf/type";
3
+ import { refsType } from "../../../controller/type";
4
+ import { activeStateType } from "../../active/type";
5
+ import { animationPropType } from "../../animation/type";
6
+ import {
7
+ airplaneColliderType,
8
+ characterColliderType,
9
+ vehicleColliderType,
10
+ } from "../../collider";
11
+ import { controlType } from "../../control/type";
12
+ import { joyStickType } from "../../joystick/type";
13
+ import { minimapType } from "../../minimap/type";
14
+ import { pointsType } from "../../point/type";
15
+ import { statesType } from "../../states/type";
16
+ import { urlType } from "../../url/type";
17
+
18
+ export type characterOptionType = {
19
+ type?: "character";
20
+ controller?: "gameboy" | "keyboard" | "joystick";
21
+ };
22
+ export type vehicleOptionType = {
23
+ type?: "vehicle";
24
+ controller?: "keyboard" | "joystick" | "steeringWheel";
25
+ };
26
+ export type airplaneOptionType = {
27
+ type?: "airplane";
28
+ controller?: "keyboard" | "joystick" | "steeringWheel";
29
+ };
30
+
31
+ export type gaesupControllerPropType =
32
+ | characterOptionType
33
+ | vehicleOptionType
34
+ | airplaneOptionType;
35
+
36
+ export type gaesupWorldPropType = {
37
+ activeState: activeStateType;
38
+ characterCollider: characterColliderType;
39
+ vehicleCollider: vehicleColliderType;
40
+ airplaneCollider: airplaneColliderType;
41
+ mode: gaesupControllerPropType;
42
+ url: urlType;
43
+ characterGltf: GLTFResult;
44
+ vehicleGltf: GLTFResult;
45
+ wheelGltf: GLTFResult;
46
+ airplaneGltf: GLTFResult;
47
+ states: statesType;
48
+ debug: boolean;
49
+ minimap: minimapType;
50
+ joystick: joyStickType;
51
+ control: controlType;
52
+ points: pointsType;
53
+ refs: refsType;
54
+ animations: animationPropType;
55
+ };
56
+
57
+ export type dispatchType<T> = Dispatch<{
58
+ type: string;
59
+ payload?: Partial<T>;
60
+ }>;
61
+
62
+ export type gaesupWorldPartialPropType = Partial<gaesupWorldPropType>;
63
+ export type gaesupDisptachType = Dispatch<{
64
+ type: string;
65
+ payload?: Partial<gaesupWorldPropType>;
66
+ }>;
@@ -0,0 +1,33 @@
1
+ import { useContext } from "react";
2
+ import {
3
+ GaesupWorldContext,
4
+ GaesupWorldDispatchContext,
5
+ } from "../context/gaesupworld";
6
+
7
+ export const controlDefault = {
8
+ forward: false,
9
+ backward: false,
10
+ leftward: false,
11
+ rightward: false,
12
+ };
13
+
14
+ export function usePushKey() {
15
+ const { control } = useContext(GaesupWorldContext);
16
+ const dispatch = useContext(GaesupWorldDispatchContext);
17
+
18
+ const pushKey = (key: string, value: boolean) => {
19
+ control[key] = value;
20
+ dispatch({
21
+ type: "update",
22
+ payload: {
23
+ control: {
24
+ ...control,
25
+ },
26
+ },
27
+ });
28
+ };
29
+
30
+ return {
31
+ pushKey,
32
+ };
33
+ }
@@ -0,0 +1,11 @@
1
+ export type controlType = {
2
+ forward: boolean;
3
+ backward: boolean;
4
+ leftward: boolean;
5
+ rightward: boolean;
6
+ [key: string]: boolean;
7
+ };
8
+
9
+ export type keyControlType = {
10
+ [key: string]: boolean;
11
+ };
@@ -0,0 +1,72 @@
1
+ import { useContext } from "react";
2
+ import {
3
+ GaesupWorldContext,
4
+ GaesupWorldDispatchContext,
5
+ } from "../context/gaesupworld";
6
+ import { joyStickBallType, joyStickOriginType } from "./type";
7
+
8
+ export const joyStickBallDefault = {
9
+ x: "50%",
10
+ y: "50%",
11
+ position: "absolute",
12
+ background: "rgba(0, 0, 0, 0.5)",
13
+ boxShadow: "0 0 10px rgba(0, 0, 0, 0.5)",
14
+ };
15
+
16
+ export const joyStickOriginDefault = {
17
+ x: 0,
18
+ y: 0,
19
+ angle: Math.PI / 2,
20
+ currentRadius: 0,
21
+ originRadius: 0,
22
+ isIn: true,
23
+ isOn: false,
24
+ };
25
+
26
+ export const joyStickDefault = {
27
+ on: false,
28
+ joyStickBall: joyStickBallDefault,
29
+ joyStickOrigin: joyStickOriginDefault,
30
+ };
31
+
32
+ export default function useJoyStick() {
33
+ const { joystick } = useContext(GaesupWorldContext);
34
+ const dispatch = useContext(GaesupWorldDispatchContext);
35
+ const { joyStickBall, joyStickOrigin } = joystick;
36
+
37
+ const setBall = (ball: joyStickBallType) => {
38
+ joystick.joyStickBall = Object.assign(joyStickBall, ball);
39
+ dispatch({
40
+ type: "update",
41
+ payload: {
42
+ joystick: {
43
+ ...joystick,
44
+ joyStickBall: {
45
+ ...joystick.joyStickBall,
46
+ },
47
+ },
48
+ },
49
+ });
50
+ };
51
+
52
+ const setOrigin = (origin: joyStickOriginType) => {
53
+ joystick.joyStickOrigin = Object.assign(joyStickOrigin, origin);
54
+ dispatch({
55
+ type: "update",
56
+ payload: {
57
+ joystick: {
58
+ ...joystick,
59
+ joyStickOrigin: {
60
+ ...joystick.joyStickOrigin,
61
+ },
62
+ },
63
+ },
64
+ });
65
+ };
66
+ return {
67
+ joyStickOrigin,
68
+ joyStickBall,
69
+ setBall,
70
+ setOrigin,
71
+ };
72
+ }
@@ -0,0 +1,23 @@
1
+ export type joyStickBallType = {
2
+ x: string;
3
+ y: string;
4
+ position: string;
5
+ background: string;
6
+ boxShadow: string;
7
+ };
8
+
9
+ export type joyStickOriginType = {
10
+ x: number;
11
+ y: number;
12
+ angle: number;
13
+ currentRadius: number;
14
+ originRadius: number;
15
+ isIn: boolean;
16
+ isOn: boolean;
17
+ };
18
+
19
+ export type joyStickType = {
20
+ on: boolean;
21
+ joyStickBall: joyStickBallType;
22
+ joyStickOrigin: joyStickOriginType;
23
+ };
@@ -0,0 +1,5 @@
1
+ export const minimapDefault = {
2
+ on: true,
3
+ ratio: 0.1,
4
+ props: {},
5
+ };
@@ -0,0 +1,22 @@
1
+ import { CSSProperties } from "react";
2
+ import * as THREE from "three";
3
+
4
+ export type minimapPropsType = {
5
+ text: string;
6
+ center: THREE.Vector3;
7
+ size: THREE.Vector3;
8
+ };
9
+
10
+ export type minimapType = {
11
+ on: boolean;
12
+ ratio?: number;
13
+ props: {
14
+ [key: string]: minimapPropsType;
15
+ };
16
+ minimapStyle?: CSSProperties;
17
+ outerStyle?: CSSProperties;
18
+ innerStyle?: CSSProperties;
19
+ textStyle?: CSSProperties;
20
+ objectStyle?: Omit<CSSProperties, "width" | "height" | "transform">;
21
+ avatarStyle?: CSSProperties;
22
+ };
@@ -0,0 +1,6 @@
1
+ export type pointType = {
2
+ text: string;
3
+ position: THREE.Vector3;
4
+ };
5
+
6
+ export type pointsType = pointType[];
@@ -0,0 +1,10 @@
1
+ export const statesDefault = {
2
+ isMoving: false,
3
+ isNotMoving: false,
4
+ isOnTheGround: false,
5
+ isOnMoving: false,
6
+ isRotated: false,
7
+ isRunning: false,
8
+ isJumping: false,
9
+ isAnimationOuter: false,
10
+ };
@@ -0,0 +1,10 @@
1
+ export type statesType = {
2
+ isMoving: boolean;
3
+ isNotMoving: boolean;
4
+ isOnTheGround: boolean;
5
+ isOnMoving: boolean;
6
+ isRotated: boolean;
7
+ isRunning: boolean;
8
+ isJumping: boolean;
9
+ isAnimationOuter: boolean;
10
+ };
@@ -0,0 +1,6 @@
1
+ export const urlDefault = {
2
+ characterUrl: null,
3
+ vehicleUrl: null,
4
+ airplaneUrl: null,
5
+ wheelUrl: null,
6
+ };
@@ -0,0 +1,6 @@
1
+ export type urlType = {
2
+ characterUrl?: string;
3
+ vehicleUrl?: string;
4
+ airplaneUrl?: string;
5
+ wheelUrl?: string;
6
+ };
@@ -0,0 +1,26 @@
1
+ import { style } from "@vanilla-extract/css";
2
+ import { fixed } from "../styles/recipe/index.css";
3
+ import { vars } from "../styles/theme.css";
4
+
5
+ export const debug = style([
6
+ fixed({
7
+ south_east: true,
8
+ }),
9
+ {
10
+ overflowY: "scroll",
11
+ margin: "2rem",
12
+ width: "40rem",
13
+ height: "30rem",
14
+ zIndex: 100000,
15
+ background: vars.themes.debug,
16
+ borderRadius: "1rem",
17
+ boxShadow: "0 0 0.5rem rgba(0, 0, 0, 0.2)",
18
+ },
19
+ ]);
20
+
21
+ export const debugItem = style({
22
+ position: "relative",
23
+ paddingLeft: "1rem",
24
+ fontSize: "0.8em",
25
+ color: vars.themes.text.normal,
26
+ });
@@ -0,0 +1,38 @@
1
+ import { usePushKey } from "../../stores/control";
2
+ import * as style from "./style.css";
3
+
4
+ export type gameBoyButtonType = {
5
+ tag: "up" | "down" | "left" | "right";
6
+ value: string;
7
+ icon: JSX.Element;
8
+ };
9
+
10
+ export default function GameBoyButton({ tag, value, icon }: gameBoyButtonType) {
11
+ const { pushKey } = usePushKey();
12
+
13
+ const onMouseDown = () => {
14
+ pushKey(value, true);
15
+ };
16
+
17
+ const onMouseLeave = () => {
18
+ pushKey(value, false);
19
+ };
20
+
21
+ return (
22
+ <button
23
+ className={`${style.gameBoyButtonRecipe({
24
+ tag: tag,
25
+ })}`}
26
+ onMouseDown={() => onMouseDown()}
27
+ onMouseUp={() => onMouseLeave()}
28
+ onMouseLeave={() => onMouseLeave()}
29
+ onContextMenu={(e) => {
30
+ e.preventDefault();
31
+ }}
32
+ onPointerDown={() => onMouseDown()}
33
+ onPointerUp={() => onMouseLeave()}
34
+ >
35
+ {icon}
36
+ </button>
37
+ );
38
+ }
@@ -0,0 +1,36 @@
1
+ import { BiDownArrow } from "@react-icons/all-files/bi/BiDownArrow";
2
+ import { BiLeftArrow } from "@react-icons/all-files/bi/BiLeftArrow";
3
+ import { BiRightArrow } from "@react-icons/all-files/bi/BiRightArrow";
4
+ import { BiUpArrow } from "@react-icons/all-files/bi/BiUpArrow";
5
+ import GameBoyButton, { gameBoyButtonType } from "./GameBoyButton";
6
+ import * as style from "./style.css";
7
+
8
+ export const GameBoyDirections = [
9
+ {
10
+ tag: "up",
11
+ value: "forward",
12
+ icon: <BiUpArrow />,
13
+ },
14
+ { tag: "down", value: "backward", icon: <BiDownArrow /> },
15
+ { tag: "left", value: "leftward", icon: <BiLeftArrow /> },
16
+ { tag: "right", value: "rightward", icon: <BiRightArrow /> },
17
+ ];
18
+
19
+ export default function GameBoy() {
20
+ return (
21
+ <div className={style.gameBoy}>
22
+ <div className={style.gameBoyInner}>
23
+ {GameBoyDirections.map((item: gameBoyButtonType, key: number) => {
24
+ return (
25
+ <GameBoyButton
26
+ key={key}
27
+ tag={item.tag}
28
+ value={item.value}
29
+ icon={item.icon}
30
+ />
31
+ );
32
+ })}
33
+ </div>
34
+ </div>
35
+ );
36
+ }
@@ -0,0 +1,78 @@
1
+ import { style } from "@vanilla-extract/css";
2
+ import { recipe } from "@vanilla-extract/recipes";
3
+ import {
4
+ fixed,
5
+ flex,
6
+ flex_relative,
7
+ glass,
8
+ grid,
9
+ } from "../../../styles/recipe/index.css";
10
+ import { vars } from "../../../styles/theme.css";
11
+
12
+ export const gameBoy = style([
13
+ fixed({
14
+ south: true,
15
+ }),
16
+ flex({
17
+ column: "6",
18
+ }),
19
+ {
20
+ width: "100%",
21
+ },
22
+ ]);
23
+
24
+ export const gameBoyInner = style([
25
+ grid({
26
+ row: "center",
27
+ }),
28
+ {
29
+ margin: "1rem",
30
+ padding: "1rem",
31
+ borderRadius: "50%",
32
+ gridTemplateColumns: "1fr 1fr 1fr",
33
+ gridTemplateRows: "1fr 1fr 1fr",
34
+ background: "rgba(0, 0, 0, 0.5)",
35
+ boxShadow: "0 0 10px rgba(0, 0, 0, 0.5)",
36
+ },
37
+ ]);
38
+
39
+ export const gameBoyButtonRecipe = recipe({
40
+ base: [
41
+ flex_relative({}),
42
+ glass({}),
43
+ {
44
+ all: "unset",
45
+ width: "3rem",
46
+ height: "3rem",
47
+ margin: "0.3rem",
48
+ borderRadius: "50%",
49
+ background: vars.gradient.green,
50
+ boxShadow: "0 0 10px #78ffd6",
51
+ fontSize: "1.6rem",
52
+ color: "black",
53
+ textShadow: "0 0 10px black",
54
+ cursor: "pointer",
55
+ transition: "all 0.3s ease-in",
56
+ },
57
+ ],
58
+ variants: {
59
+ tag: {
60
+ up: {
61
+ gridRow: "1/2",
62
+ gridColumn: "2/3",
63
+ },
64
+ left: {
65
+ gridRow: "2/3",
66
+ gridColumn: "1/2",
67
+ },
68
+ down: {
69
+ gridRow: "3/4",
70
+ gridColumn: "2/3",
71
+ },
72
+ right: {
73
+ gridRow: "2/3",
74
+ gridColumn: "3/4",
75
+ },
76
+ },
77
+ },
78
+ });
@@ -0,0 +1,31 @@
1
+ import { usePushKey } from "../../stores/control";
2
+ import * as style from "./style.css";
3
+
4
+ export default function GamePadButton({ value }: { value: string }) {
5
+ const { pushKey } = usePushKey();
6
+
7
+ const onMouseDown = () => {
8
+ pushKey(value, true);
9
+ };
10
+
11
+ const onMouseLeave = () => {
12
+ pushKey(value, false);
13
+ };
14
+
15
+ return (
16
+ <button
17
+ className={`${style.gamePadButtonRecipe}`}
18
+ onMouseDown={() => onMouseDown()}
19
+ onMouseUp={() => onMouseLeave()}
20
+ onMouseLeave={() => onMouseLeave()}
21
+ onContextMenu={(e) => {
22
+ e.preventDefault();
23
+ onMouseLeave();
24
+ }}
25
+ onPointerDown={() => onMouseDown()}
26
+ onPointerUp={() => onMouseLeave()}
27
+ >
28
+ {value}
29
+ </button>
30
+ );
31
+ }
@@ -0,0 +1,55 @@
1
+ import { BiDownArrow } from "@react-icons/all-files/bi/BiDownArrow";
2
+ import { BiLeftArrow } from "@react-icons/all-files/bi/BiLeftArrow";
3
+ import { BiRightArrow } from "@react-icons/all-files/bi/BiRightArrow";
4
+ import { BiUpArrow } from "@react-icons/all-files/bi/BiUpArrow";
5
+ import { useContext } from "react";
6
+ import { GaesupWorldContext } from "../../stores/context/gaesupworld";
7
+
8
+ type gameBoyDirectionType = {
9
+ tag: string;
10
+ value: string;
11
+ icon: JSX.Element;
12
+ };
13
+
14
+ export const GameBoyDirections = [
15
+ {
16
+ tag: "up",
17
+ value: "forward",
18
+ icon: <BiUpArrow />,
19
+ },
20
+ { tag: "down", value: "backward", icon: <BiDownArrow /> },
21
+ { tag: "left", value: "leftward", icon: <BiLeftArrow /> },
22
+ { tag: "right", value: "rightward", icon: <BiRightArrow /> },
23
+ ];
24
+
25
+ export default function GamePad() {
26
+ const { control } = useContext(GaesupWorldContext);
27
+ const { mode } = useContext(GaesupWorldContext);
28
+ const GamePadDirections = Object.keys(control)
29
+ .map((key) => {
30
+ if (
31
+ key !== "forward" &&
32
+ key !== "backward" &&
33
+ key !== "leftward" &&
34
+ key !== "rightward"
35
+ )
36
+ return {
37
+ tag: key,
38
+ value: key,
39
+ };
40
+ })
41
+ .filter((item) => item !== undefined)
42
+ .filter(
43
+ (item: gameBoyDirectionType) =>
44
+ !(item.tag === "run" && mode.controller === "joystick")
45
+ );
46
+
47
+ return (
48
+ <></>
49
+ // <div className={style.gamePad}>
50
+ // {GamePadDirections.map((item: gameBoyDirectionType, key: number) => {
51
+ // return <GamePadButton key={key} value={item.value} />;
52
+ // })}
53
+ // </div>
54
+ );
55
+ }