Back
Version 51
11/5/2024
/** @jsxImportSource https://esm.sh/react */
import React, { useCallback, useEffect, useRef, useState } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
const SPEED = 6; // pixels per step
const FRAME_TIME = 80; // milliseconds per frame
const BEHAVIOR_MIN_TIME = 5000; // minimum milliseconds per behavior
const SPRITE_SIZE = 96;
const ROW_INDEX = {
"right-walk": 0,
"up-walk": 1,
"left-walk": 2,
"down-walk": 3,
"right-idle": 4,
"up-idle": 5,
"left-idle": 6,
"down-idle": 7,
};
type Behavior = "idle" | "wander" | "follow";
type AnimationDirection = "right" | "up" | "left" | "down";
type AnimationCycle = "walk" | "idle";
type AnimationLabel = `${AnimationDirection}-${AnimationCycle}`;
interface PetState {
behavior: Behavior;
animation: AnimationLabel;
frameIndex: number;
x: number;
y: number;
behaviorChange: number;
goalPos?: { x: number; y: number };
}
interface MouseState {
x: number;
midnightlightning-mooncatwalk.web.val.run
Updated: November 5, 2024