feat: add CREATURE_SPEED and FLASHLIGHT_INTENSITY_BASE

This commit is contained in:
2026-06-01 15:08:03 -03:00
parent 20b6a559fd
commit dd5e8a2ae2
3 changed files with 5 additions and 4 deletions
+2 -3
View File
@@ -3,7 +3,7 @@ import { useFrame, useThree } from "@react-three/fiber";
import { useEffect, useRef, useState } from "react"; import { useEffect, useRef, useState } from "react";
import * as THREE from "three"; import * as THREE from "three";
import { fearState } from "../state"; import { FEAR_SETTINGS, fearState } from "../state";
export default function TheCreature() { export default function TheCreature() {
const texture = useTexture('fear/img/creature.png'); const texture = useTexture('fear/img/creature.png');
@@ -14,7 +14,6 @@ export default function TheCreature() {
const [hasTriggered, setHasTriggered] = useState(false); const [hasTriggered, setHasTriggered] = useState(false);
const [isSpawned, setIsSpawned] = useState(false); const [isSpawned, setIsSpawned] = useState(false);
const speed = 15;
const globalDistance = useRef<number>(32); const globalDistance = useRef<number>(32);
const [currentLoop, setCurrentLoop] = useState(fearState.loopCount); const [currentLoop, setCurrentLoop] = useState(fearState.loopCount);
@@ -56,7 +55,7 @@ export default function TheCreature() {
} }
if (hasTriggered) { if (hasTriggered) {
globalDistance.current -= speed * delta; globalDistance.current -= FEAR_SETTINGS.CREATURE_SPEED * delta;
if (audioRef.current && !audioPlaying.current) { if (audioRef.current && !audioPlaying.current) {
audioPlaying.current = true; audioPlaying.current = true;
+1 -1
View File
@@ -92,7 +92,7 @@ export default function Player() {
flashlightRef.current.target.position.lerp(targetDest, 10 * delta); flashlightRef.current.target.position.lerp(targetDest, 10 * delta);
flashlightRef.current.target.updateMatrixWorld(); flashlightRef.current.target.updateMatrixWorld();
flashlightRef.current.intensity = 5 + Math.sin(state.clock.elapsedTime * 30) * 0.3; flashlightRef.current.intensity = FEAR_SETTINGS.FLASHLIGHT_INTENSITY_BASE + Math.sin(state.clock.elapsedTime * 30) * 0.3;
} }
const minX = -fearState.currentWidth / 2 + FEAR_SETTINGS.WALL_BUFFER; const minX = -fearState.currentWidth / 2 + FEAR_SETTINGS.WALL_BUFFER;
+2
View File
@@ -6,7 +6,9 @@ export const FEAR_SETTINGS = {
HALLWAY_HEIGHT: 5, HALLWAY_HEIGHT: 5,
PLAYER_HEIGHT: 3, PLAYER_HEIGHT: 3,
PLAYER_SPEED: 4, PLAYER_SPEED: 4,
FLASHLIGHT_INTENSITY_BASE: 8,
WALL_BUFFER: 0.6, WALL_BUFFER: 0.6,
CREATURE_SPEED: 12,
}; };
const listeners = new Set<() => void>(); const listeners = new Set<() => void>();