The classic desktop cat, now Object-Oriented and Typesafe.
Why rewrite a decades-old script in TypeScript?
- Because we all love typesafe code.
- I want to have 200 cats running over my screen.
- Just because I can (use of free will).
First, import the class. It’s strictly typed, so the cat won't throw a tantrum (runtime error) unexpectedly.
import { Oneko } from './Oneko';This spawns a standard cat. It will judge your mouse movements immediately.
const cat = new Oneko();You can customize your new friend. Giving them speed makes them aggressive. Giving them offsets makes them socially distant.
const zoomy = new Oneko({
src: './oneko.gif', // Your own sprite if you want a dog (blasphemy)
speed: 40, // 4x speed (The Zoomies)
x: 500, // Spawn location X
y: 200, // Spawn location Y
xOffset: 32, // Stop 32px away from the cursor
yOffset: 32 // Stop 32px away from the cursor
});If the cat is distracting you from actual work (unlikely, the cat is the work), you can banish it.
zoomy.destroy();It's TypeScript, but we use Bun because we value our time.
Just run:
bunx tsc oneko.tsIf you use Vite, just import it and pretend build steps don't exist.
- Logic adapted from adryd325/oneko.js.
- Original BSD/Public Domain Neko software.