Skip to content

TiHNs-Lab/oneko.ts

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

oneko.ts 🐈

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).

Usage

1. Summon the Cat

First, import the class. It’s strictly typed, so the cat won't throw a tantrum (runtime error) unexpectedly.

import { Oneko } from './Oneko';

2. The "Just Give Me a Cat" Method

This spawns a standard cat. It will judge your mouse movements immediately.

const cat = new Oneko();

3. The "I Want a Specific Cat" Method

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
});

4. Make it Go Away

If the cat is distracting you from actual work (unlikely, the cat is the work), you can banish it.

zoomy.destroy();

Development

It's TypeScript, but we use Bun because we value our time.

Just run:

bunx tsc oneko.ts

If you use Vite, just import it and pretend build steps don't exist.

Credits

About

TypeScript rewrite of oneko.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%