This commit is contained in:
ad044 2021-03-09 16:09:47 +04:00
parent 65d16f7e3f
commit 75bf23f8ef
5 changed files with 18 additions and 31 deletions

View file

@ -1,7 +1,7 @@
import React, { useEffect } from "react"; import React, { useEffect } from "react";
import "./static/css/page.css"; import "./static/css/page.css";
import Game from "./dom-components/Game"; import Game from "./dom-components/Game";
import { BrowserRouter, Route, Switch } from "react-router-dom"; import { HashRouter, Route, Switch } from "react-router-dom";
import Notes from "./dom-components/Notes"; import Notes from "./dom-components/Notes";
const App = () => { const App = () => {
@ -10,12 +10,12 @@ const App = () => {
}, []); }, []);
return ( return (
<BrowserRouter> <HashRouter>
<Switch> <Switch>
<Route path={"/"} exact component={Notes} /> <Route path={"/"} exact component={Notes} />
<Route path={"/game"} exact component={Game} /> <Route path={"/game"} exact component={Game} />
</Switch> </Switch>
</BrowserRouter> </HashRouter>
); );
}; };

View file

@ -17,7 +17,6 @@ import handleEvent from "../core/handleEvent";
import { GameEvent } from "../types/types"; import { GameEvent } from "../types/types";
import { MouseEvent, useLoader } from "react-three-fiber"; import { MouseEvent, useLoader } from "react-three-fiber";
import circleButton from "../static/sprites/controller/circle.png"; import circleButton from "../static/sprites/controller/circle.png";
import squareButton from "../static/sprites/controller/square.png";
import triangleButton from "../static/sprites/controller/triangle.png"; import triangleButton from "../static/sprites/controller/triangle.png";
import crossButton from "../static/sprites/controller/cross.png"; import crossButton from "../static/sprites/controller/cross.png";
import startButton from "../static/sprites/controller/start.png"; import startButton from "../static/sprites/controller/start.png";
@ -36,7 +35,6 @@ const InputHandler = (props: InputHandlerProps) => {
const circleButtonTex = useLoader(THREE.TextureLoader, circleButton); const circleButtonTex = useLoader(THREE.TextureLoader, circleButton);
const crossButtonTex = useLoader(THREE.TextureLoader, crossButton); const crossButtonTex = useLoader(THREE.TextureLoader, crossButton);
const squareButtonTex = useLoader(THREE.TextureLoader, squareButton);
const triangleButtonTex = useLoader(THREE.TextureLoader, triangleButton); const triangleButtonTex = useLoader(THREE.TextureLoader, triangleButton);
const startButtonTex = useLoader(THREE.TextureLoader, startButton); const startButtonTex = useLoader(THREE.TextureLoader, startButton);
const l2ButtonTex = useLoader(THREE.TextureLoader, l2Button); const l2ButtonTex = useLoader(THREE.TextureLoader, l2Button);
@ -54,8 +52,8 @@ const InputHandler = (props: InputHandlerProps) => {
now > timeSinceLastKeyPress.current + inputCooldown && now > timeSinceLastKeyPress.current + inputCooldown &&
inputCooldown !== -1 inputCooldown !== -1
) { ) {
if (scene === "main") {
timeSinceLastKeyPress.current = now; timeSinceLastKeyPress.current = now;
if (scene === "main") {
lainIdleTimerRef.current = now; lainIdleTimerRef.current = now;
idleSceneTimerRef.current = now; idleSceneTimerRef.current = now;
} }
@ -250,19 +248,6 @@ const InputHandler = (props: InputHandlerProps) => {
opacity={0.8} opacity={0.8}
/> />
</sprite> </sprite>
<sprite
scale={[1.5, 1.5, 0]}
position={[-1, 0, 0]}
onClick={handleVirtualButtonPress}
name={"square"}
>
<spriteMaterial
attach="material"
map={squareButtonTex}
depthTest={false}
opacity={0.8}
/>
</sprite>
</group> </group>
</> </>
)} )}

View file

@ -49,7 +49,7 @@ export const siteMoveHorizontal = (calculatedState: {
delay: 3900, delay: 3900,
}, },
], ],
audio: [{ sfx: [audio.sound6, audio.sound34], delay: 1100 }], audio: [{ sfx: [audio.sound6] }, { sfx: [audio.sound34], delay: 1100 }],
}); });
export const siteMoveVertical = (calculatedState: { export const siteMoveVertical = (calculatedState: {
@ -360,12 +360,7 @@ export const saveGame = (calculatedState: {
export const loadGameFail = { export const loadGameFail = {
state: [ state: [
{ { mutation: { loadSuccessful: false, inputCooldown: 1200 } },
mutation: {
loadSuccessful: false,
inputCooldown: 1200,
},
},
{ mutation: { loadSuccessful: undefined }, delay: 1200 }, { mutation: { loadSuccessful: undefined }, delay: 1200 },
], ],
audio: [{ sfx: [audio.sound28] }], audio: [{ sfx: [audio.sound28] }],

View file

@ -155,10 +155,14 @@ const handleMainSceneInput = (
const upperLimit = activeSite === "a" ? 22 : 13; const upperLimit = activeSite === "a" ? 22 : 13;
if ( if (
(direction === "up" && level === upperLimit) || (activeNode.matrixIndices?.rowIdx === 0 &&
(direction === "down" && level === 1) direction === "up" &&
level === upperLimit) ||
(activeNode.matrixIndices?.rowIdx === 2 &&
direction === "down" &&
level === 1)
) )
return; return resetInputCooldown;
const nodeData = findNode( const nodeData = findNode(
activeNode, activeNode,
@ -175,6 +179,7 @@ const handleMainSceneInput = (
const newLevel = (direction === "up" ? level + 1 : level - 1) const newLevel = (direction === "up" ? level + 1 : level - 1)
.toString() .toString()
.padStart(2, "0"); .padStart(2, "0");
const newNode = { const newNode = {
...(nodeData.node !== "unknown" ...(nodeData.node !== "unknown"
? getNodeById(nodeData.node, activeSite) ? getNodeById(nodeData.node, activeSite)
@ -184,6 +189,7 @@ const handleMainSceneInput = (
if (nodeData.didMove) { if (nodeData.didMove) {
if (!canLainMove) return resetInputCooldown; if (!canLainMove) return resetInputCooldown;
return siteMoveVertical({ return siteMoveVertical({
lainMoveAnimation: lainMoveAnimation, lainMoveAnimation: lainMoveAnimation,
activeLevel: newLevel, activeLevel: newLevel,

View file

@ -1,5 +1,6 @@
import React from "react"; import React from "react";
import "../static/css/notes.css"; import "../static/css/notes.css";
import { Link } from "react-router-dom";
const Notes = () => { const Notes = () => {
return ( return (
@ -12,7 +13,7 @@ const Notes = () => {
</td> </td>
<td> <td>
<p> <p>
The game performs best on chromium-based browsers. Chromium, The game performs best on chromium-based browsers - Chromium,
Chrome, Edge, Brave, Opera, Iridium, Vivaldi, etc. It's highly Chrome, Edge, Brave, Opera, Iridium, Vivaldi, etc. It's highly
recommended that you use one of those for an optimal experience. recommended that you use one of those for an optimal experience.
This is especially true if you're using a bad setup, and even This is especially true if you're using a bad setup, and even
@ -148,7 +149,7 @@ const Notes = () => {
</tr> </tr>
</tbody> </tbody>
</table> </table>
<a href="/game">start</a> <Link to="/game">start</Link>
<br /> <br />
</> </>
); );