Pixl is a browser pet with a clock, three counters and SVG sprites. Its rules decide when it sleeps, gets hungry or looks happy.
A pocket pet in the browser#
The visual reference is the pocket pet: a small creature with needs you can read on a tiny screen.
![]()
Pixl uses deterministic rules to choose what the pet does. There is no server, no randomness, no
hidden neural net. Only the browser’s Date object, three integers, and
a handful of SVG sprites that look best on a pretend-CRT background.1

Three changing values#
| Stat | Role | Good direction |
|---|---|---|
happiness |
emotional brightness | higher |
hunger |
distance from a full tummy | lower |
energy |
readiness to bounce on the screen | higher |
Every 30s the numbers drift:
Left alone for half an hour Pixl grows hungry, drowsy, and a little gloomy.

Following the local clock#
The clock is local to each visitor. A laptop in Tokyo and a phone in Tijuana can therefore show different scenes at the same instant. The pet stats are stored in each browser, too; there is no shared global creature.
Five rules#
-
Circadian
Pixl dozes whenever the local clock reads between 10 PM and 5 AM. -
Dominant Need
Physical necessities outrank mood: starving pixels grumble, exhausted ones sag. -
Mood Gradient
The emotional dial swings between 😊 , 😐 , and 😢 depending on morale. -
Reinforcement
More than five petting and playing interactions in 24 hours can trigger the ecstatic animation when Pixl is already happy. -
Scarcity of Kindness
Each action is limited to three uses per day.

The rules form a small hierarchy: hunger and fatigue take priority over mood.2
Drawing the sprites#
All art is plain SVG— or grids rendered with the
property shapeRendering="crispEdges". The grids keep the shapes simple and the edges sharp.

A sleeping Pixl, eyes closed.
A Walk Through the Source#
Conceived as a single event-loop, Pixl’s logic is a few hundred lines of
lightweight JavaScript. The core function, tick, runs every 30
seconds, updating the creature’s state and rendering the scene.
function tick(now):
stats ← loadStats() # from localStorage
stats ← decay(stats) # metabolic drift
scenery ← chooseScenery(now)
animation ← chooseAnimation(stats, now)
render(scenery, animation, stats)
A few key functions drive the experience:
- chooseScenery maps
(month, hour)to spring morning, autumn night, or—on 25 December—christmas. - chooseAnimation applies the five axioms above.
- Persistence is two keys in
localStorage: one JSON object forstats, one ring-buffer for the last 100 interactions.
The sprites and state transitions invite the viewer to read a personality into a small set of rules.
Implementation in Brief#
| Layer | Choice & Rationale |
|---|---|
| Framework | Next.js 14, App Router – static export, zero backend needed |
| State & I/O | React hooks + localStorage |
| Art Pipeline | In-code SVG sprites (shapeRendering="crispEdges") |
| Styling | Tailwind; font VT323 for gentle CRT nostalgia |
| Hosting | Static files on GitHub Pages |
Clothing, behaviour and scenery are possible additions to the project.
Reading a personality into the rules#
Pixl is a small experiment in making a handful of rules visible. The interesting question is how much personality a clock, changing stats and a few sprites can suggest—and which interactions make those rules clear to the person playing.
![]()
Footnotes
-
Using
shapeRendering="crispEdges"forces the browser to snap edges to the pixel grid, preventing the antialias blur that would otherwise undermine the retro aesthetic. ↩ -
The hierarchy here is a design metaphor for choosing an animation: hunger and fatigue take priority over mood. It is a set of rules for a toy, rather than a psychological model. ↩