How to make your own desktop pet
A desktop pet is a see-through window on top of everything, some pictures of an animal, and a few simple rules. You can make one with Python or Electron, or skip the code and use an app that lets you add your own pet.
Updated
How are desktop pets built?
A desktop pet is built from three parts: a window you can see through, a set of pictures for each action, and a small program that decides what the pet does next. That is all. Everything else, such as dragging the pet or feeding it, comes later.
How do you make the window see-through and always on top?
You make a window with no frame, no background, and a setting that keeps it above other windows. Then you let clicks pass through the empty parts.
In Electron, a JavaScript tool for desktop apps, the window options look like this:
const win = new BrowserWindow({
transparent: true,
frame: false,
alwaysOnTop: true,
});
win.setIgnoreMouseEvents(true, { forward: true });
In Python, the built-in tkinter library can do a simple version on Windows:
root.overrideredirect(True)
root.attributes('-topmost', True)
root.attributes('-transparentcolor', 'white')
Here, anything drawn in white becomes see-through. The two options work differently, so read each one's documentation for the details.
What are sprite frames?
Sprite frames are the separate pictures that make an animation, like a flip-book. A walking cat might be six small images in a row. You show them one after another, a few times a second, and the cat seems to walk. You need a set for each action, such as walk, sit and sleep. A pixel-art editor is enough to draw them.
What is a state machine, and why does a pet need one?
A state machine is a list of what the pet can be doing, and the rules for moving from one to the next. It is how a pet seems to make choices.
- Walk: move a few pixels each step. After a while, pick sit or sleep.
- Sit: stay still for a few seconds. Then walk again.
- Sleep: stay still for longer. Wake up if the mouse comes close.
Add a bit of randomness to the timing, and the pet no longer looks like a machine.
What is a good beginner path?
Start with one pet that does two things. Then add more, step by step:
- Show a transparent window with one still picture.
- Make it flip between two frames so it looks alive.
- Move it along the bottom of the screen.
- Add sit and sleep, with the state machine above.
- Let the clicks pass through, then add a click that makes the pet react.
Python is easier to read. Electron is a good choice if you already know web pages, because the pet is just an HTML page. Both are free.
Can I get a custom desktop pet without coding?
Yes. Some apps let you add your own characters. Shimeji and Shijima, for instance, take characters made by fans, which you can read about in the best desktop pets.
In Purrminal, Premium adds "your own cat, made from a photo". Check pricing for exactly what is included. Every one of the 16 built-in pets can be earned for free, and you can meet them all.
What mistakes do beginners make?
The most common mistake is building too much too early. A pet with ten actions and no stable window is harder to finish than a pet with two actions that works. Get one animation running smoothly first.
Another is forgetting about screens. If you have two monitors, the pet should know where the edges are. Test on the second screen early, or the pet will walk off the edge and vanish.
A third is using too much power. Redraw only when something changes, and keep the frame rate modest. A pet that makes the laptop fan spin is not a good pet.
Finally, keep your art tidy. Use the same size for every frame, and put the feet in the same place, or the pet will seem to jump around as it moves.
Where can I learn more?
Start with what desktop pets are. The open-source desktopPet project is MIT licensed, so you can read how a real pet app works.
What do I need to get started?
You need a text editor, Python or Node.js installed, and a few pictures. That is enough for a first pet. Draw the frames in any pixel-art tool, save them as PNG files with a see-through background, and load them in your program.
Take it slowly. A first pet that blinks and walks across the screen is a real result. If you would rather play than build, Purrminal installs in a few seconds and starts you with a free cat.
Common questions
What language is best for making a desktop pet?
Python is the gentlest to start with, and Electron suits anyone who already knows HTML and JavaScript.
Do I need to draw the pet myself?
You need some pictures. You can draw simple pixel art yourself, or use art you have the right to use.
How do I stop my pet from blocking my clicks?
Let mouse events pass through the window. In Electron that is setIgnoreMouseEvents, and other tools have a similar setting.
Can I make a pet from a photo of my own pet?
Purrminal Premium includes your own cat, made from a photo. See pricing.