追鼠标的小猫
oneko.js,adryd,2022 年

正在布展…
它是怎么做的
- 第 1 步一个固定定位的 div,背景是精灵图(sprite sheet)。
- 第 2 步每 100ms 一步,朝鼠标方向移动固定距离。
- 第 3 步根据方向向量选择八方向奔跑帧,改变 background-position。
- 第 4 步距离足够近时进入闲置状态机:坐、挠、睡。
复刻配方
一段技术配方,可以直接交给 AI 编程助手,也可以自己照着写。想指定技术栈、位置和性能预算,就把它加入实现方案。
Draw or commission your own small pixel sprite sheet with run cycles for eight directions plus idle actions. Place a fixed 32x32 element with image-rendering: pixelated and step it on a slow interval (around 10 fps) toward the last pointer position by a constant distance. Choose the direction frame from the sign of dx and dy, alternate two frames for running, and when within a threshold switch to an idle timer that escalates from sitting to scratching to sleeping. Disable on touch devices and under reduced motion.


