mirror of
https://github.com/ad044/lainTSX.git
synced 2024-10-22 23:19:06 +00:00
fixed spritesheets, should work properly now
This commit is contained in:
parent
75c838c7bf
commit
f0be5368d2
8 changed files with 87 additions and 52 deletions
|
@ -38,8 +38,8 @@ const App = () => {
|
|||
return (
|
||||
<div id="game-root" className="game">
|
||||
<span className="canvas">
|
||||
<EventManager />
|
||||
<Canvas concurrent>
|
||||
<EventManager />
|
||||
<Suspense fallback={null}>
|
||||
{dispatchScene[currentScene as keyof typeof dispatchScene]}
|
||||
</Suspense>
|
||||
|
|
|
@ -82,8 +82,8 @@ export const LainIntro = () => (
|
|||
export const LainStanding = () => (
|
||||
<LainConstructor
|
||||
sprite={standingSpriteSheet}
|
||||
frameCount={3}
|
||||
framesHorizontal={3}
|
||||
frameCount={1}
|
||||
framesHorizontal={1}
|
||||
framesVertical={1}
|
||||
/>
|
||||
);
|
||||
|
@ -100,18 +100,20 @@ export const LainMoveDown = () => (
|
|||
export const LainMoveLeft = () => (
|
||||
<LainConstructor
|
||||
sprite={moveLeftSpriteSheet}
|
||||
frameCount={47}
|
||||
framesHorizontal={8}
|
||||
framesVertical={6}
|
||||
frameCount={46}
|
||||
framesHorizontal={7}
|
||||
framesVertical={7}
|
||||
fps={0.28 * 46}
|
||||
/>
|
||||
);
|
||||
|
||||
export const LainMoveRight = () => (
|
||||
<LainConstructor
|
||||
sprite={moveRightSpriteSheet}
|
||||
frameCount={47}
|
||||
framesHorizontal={8}
|
||||
framesVertical={6}
|
||||
frameCount={46}
|
||||
framesHorizontal={7}
|
||||
framesVertical={7}
|
||||
fps={0.28 * 46}
|
||||
/>
|
||||
);
|
||||
|
||||
|
@ -353,35 +355,39 @@ type LainProps = {
|
|||
const Lain = (props: LainProps) => {
|
||||
const lainMoveState = useLainStore((state) => state.lainMoveState);
|
||||
|
||||
const lainAnimationDispatch = {
|
||||
standing: <LainStanding />,
|
||||
site_left: <LainMoveLeft />,
|
||||
site_right: <LainMoveRight />,
|
||||
site_up: <LainMoveUp />,
|
||||
site_down: <LainMoveDown />,
|
||||
select_level_down: <LainMoveDown />,
|
||||
select_level_up: <LainMoveUp />,
|
||||
throw_node: <LainThrowNode />,
|
||||
pause_game: <LainRipMiddleRing />,
|
||||
rip_node: <LainRipNode />,
|
||||
prayer: <LainPrayer />,
|
||||
scratch_head: <LainScratchHead />,
|
||||
spin: <LainSpin />,
|
||||
stretch: <LainStretch />,
|
||||
stretch_2: <LainStretch2 />,
|
||||
thinking: <LainThinking />,
|
||||
touch_sleeve: <LainTouchSleeve />,
|
||||
blush: <LainBlush />,
|
||||
hands_behind_head: <LainHandsBehindHead />,
|
||||
hands_on_hips: <LainHandsOnHips />,
|
||||
hands_on_hips_2: <LainHandsOnHips2 />,
|
||||
hands_together: <LainHandsTogether />,
|
||||
lean_forward: <LainLeanForward />,
|
||||
lean_left: <LainLeanLeft />,
|
||||
lean_right: <LainLeanRight />,
|
||||
look_around: <LainLookAround />,
|
||||
play_with_hair: <LainPlayWithHair />,
|
||||
};
|
||||
const lainAnimationDispatch = useMemo(() => {
|
||||
const anims = {
|
||||
standing: <LainStanding />,
|
||||
site_left: <LainMoveLeft />,
|
||||
site_right: <LainMoveRight />,
|
||||
site_up: <LainMoveUp />,
|
||||
site_down: <LainMoveDown />,
|
||||
select_level_down: <LainMoveDown />,
|
||||
select_level_up: <LainMoveUp />,
|
||||
throw_node: <LainThrowNode />,
|
||||
pause_game: <LainRipMiddleRing />,
|
||||
rip_node: <LainRipNode />,
|
||||
prayer: <LainPrayer />,
|
||||
scratch_head: <LainScratchHead />,
|
||||
spin: <LainSpin />,
|
||||
stretch: <LainStretch />,
|
||||
stretch_2: <LainStretch2 />,
|
||||
thinking: <LainThinking />,
|
||||
touch_sleeve: <LainTouchSleeve />,
|
||||
blush: <LainBlush />,
|
||||
hands_behind_head: <LainHandsBehindHead />,
|
||||
hands_on_hips: <LainHandsOnHips />,
|
||||
hands_on_hips_2: <LainHandsOnHips2 />,
|
||||
hands_together: <LainHandsTogether />,
|
||||
lean_forward: <LainLeanForward />,
|
||||
lean_left: <LainLeanLeft />,
|
||||
lean_right: <LainLeanRight />,
|
||||
look_around: <LainLookAround />,
|
||||
play_with_hair: <LainPlayWithHair />,
|
||||
};
|
||||
|
||||
return anims[lainMoveState as keyof typeof anims];
|
||||
}, [lainMoveState]);
|
||||
|
||||
const [introFinished, setIntroFinished] = useState(false);
|
||||
|
||||
|
@ -398,13 +404,7 @@ const Lain = (props: LainProps) => {
|
|||
return (
|
||||
<Suspense fallback={null}>
|
||||
<sprite scale={[4.5, 4.5, 4.5]} position={[0, -0.15, 0]}>
|
||||
{stopIntroAnim ? (
|
||||
lainAnimationDispatch[
|
||||
lainMoveState as keyof typeof lainAnimationDispatch
|
||||
]
|
||||
) : (
|
||||
<LainIntro />
|
||||
)}
|
||||
{stopIntroAnim ? lainAnimationDispatch : <LainIntro />}
|
||||
</sprite>
|
||||
</Suspense>
|
||||
);
|
||||
|
|
|
@ -3,13 +3,10 @@ import HUD from "./SyncedComponents/HUD";
|
|||
import GreenTextRenderer from "../TextRenderer/GreenTextRenderer";
|
||||
import YellowTextRenderer from "../TextRenderer/YellowTextRenderer";
|
||||
import YellowOrb from "./SyncedComponents/YellowOrb";
|
||||
import LevelSelection from "./SyncedComponents/LevelSelection";
|
||||
import GrayPlanes from "./SyncedComponents/GrayPlanes";
|
||||
import Starfield from "./SyncedComponents/Starfield";
|
||||
import Site from "./SyncedComponents/Site";
|
||||
import MiddleRing from "./SyncedComponents/MiddleRing";
|
||||
import { a } from "@react-spring/three";
|
||||
import NodeExplosion from "./SyncedComponents/Site/NodeAnimations/NodeExplosion";
|
||||
|
||||
type SyncedComponentLoaderProps = {
|
||||
paused: boolean;
|
||||
|
|
|
@ -21,7 +21,7 @@ const HUD = () => {
|
|||
bigHUDPositionX: active,
|
||||
longHUDPositionX: active,
|
||||
boringHUDPositionX: active,
|
||||
config: { duration: 500 },
|
||||
config: { duration: 400 },
|
||||
});
|
||||
|
||||
const bigHUDPosX = hudElementState.bigHUDPositionX.to(
|
||||
|
|
|
@ -12,7 +12,7 @@ const GreenTextRenderer = () => {
|
|||
|
||||
const { greenTextPosXToggle } = useSpring({
|
||||
greenTextPosXToggle: greenTextActive,
|
||||
config: { duration: 500 },
|
||||
config: { duration: 400 },
|
||||
});
|
||||
|
||||
const greenTextPosX = greenTextPosXToggle.to(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import React, { useCallback, useEffect, useState } from "react";
|
||||
import React, { useCallback, useEffect, useRef, useState } from "react";
|
||||
import SiteManager from "./MainSceneManagers/SiteManager";
|
||||
import MiddleRingManager from "./MainSceneManagers/MiddleRingManager";
|
||||
import LainManager from "./MainSceneManagers/LainManager";
|
||||
|
@ -36,6 +36,7 @@ import PauseComponentManager from "./MainSceneManagers/PauseComponentManager";
|
|||
import MediaYellowTextManager from "./MediaYellowTextManager";
|
||||
import GameSaver from "./GameSaver";
|
||||
import GameLoader from "./GameLoader";
|
||||
import { useFrame } from "react-three-fiber";
|
||||
|
||||
const getKeyCodeAssociation = (keyCode: number): string => {
|
||||
const keyCodeAssocs = {
|
||||
|
@ -137,6 +138,42 @@ const EventManager = () => {
|
|||
|
||||
const [inputCooldown, setInputCooldown] = useState(false);
|
||||
|
||||
const timePassedSinceLastKeyPress = useRef(-1);
|
||||
|
||||
useFrame(() => {
|
||||
const now = Date.now();
|
||||
if (
|
||||
timePassedSinceLastKeyPress.current > -1 &&
|
||||
currentScene === "main" &&
|
||||
now > timePassedSinceLastKeyPress.current + 10000 &&
|
||||
mainSubscene !== "pause"
|
||||
) {
|
||||
const moves = [
|
||||
"prayer",
|
||||
"touch_sleeve",
|
||||
"thinking",
|
||||
"stretch_2",
|
||||
"stretch",
|
||||
"spin",
|
||||
"scratch_head",
|
||||
"blush",
|
||||
"hands_behind_head",
|
||||
"hands_on_hips",
|
||||
"hands_on_hips_2",
|
||||
"hands_together",
|
||||
"lean_forward",
|
||||
"lean_left",
|
||||
"lean_right",
|
||||
"look_around",
|
||||
"play_with_hair",
|
||||
];
|
||||
|
||||
const event = moves[Math.floor(Math.random() * moves.length)];
|
||||
setEventState({ event: event });
|
||||
timePassedSinceLastKeyPress.current = now - 2500;
|
||||
}
|
||||
});
|
||||
|
||||
const handleKeyPress = useCallback(
|
||||
(event) => {
|
||||
const { keyCode } = event;
|
||||
|
@ -144,6 +181,7 @@ const EventManager = () => {
|
|||
const keyPress = getKeyCodeAssociation(keyCode);
|
||||
|
||||
if (keyPress && !inputCooldown) {
|
||||
timePassedSinceLastKeyPress.current = Date.now() + 2500;
|
||||
let event;
|
||||
switch (currentScene) {
|
||||
case "main":
|
||||
|
|
|
@ -228,7 +228,6 @@ const MiddleRingManager = (props: any) => {
|
|||
const dispatchedObject = dispatchObject(props.eventState);
|
||||
|
||||
if (dispatchedObject) {
|
||||
console.log(dispatchedObject);
|
||||
dispatchedObject.action.apply(null, dispatchedObject.value as any);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -609,3 +609,4 @@ export const useEndSceneStore = create<EndState>((set) => ({
|
|||
set((state) => ({ mediaPlayedCount: state.mediaPlayedCount + 1 })),
|
||||
resetMediaPlayedCount: () => set(() => ({ mediaPlayedCount: 0 })),
|
||||
}));
|
||||
|
||||
|
|
Loading…
Reference in a new issue