Inspiration
How to Build a Fictional 1990s Virtual Pet Toy in the Browser Using Claude 3.5 Sonnet and SVG
Relive the anxiety of keeping a pixelated digital dinosaur alive. Here is how to prompt Claude 3.5 Sonnet to write a fully interactive, self-contained 90s virtual pet simulation using vanilla JS and SVG.
Updated 11/1/2026
The Glorious Anxiety of the Pocket-Sized Toy
If you went to school in the late 1990s, you probably remember the distinct dread of keeping a digital creature alive during a double-period history lesson. The frantic, silent button mashing under the desk. The high-pitched beeping that inevitably gave you away to the teacher.
We are going to recreate that specific brand of nostalgia today. Not by loading up some massive, modern game engine, but by coaxing Claude 3.5 Sonnet into building a fully interactive, self-contained virtual pet toy directly inside a single HTML file. No external assets, no heavy libraries—just raw SVG, CSS, and native JavaScript state management.
This project is an exceptional exercise in code compacting. It forces the LLM to write highly efficient vector graphics, handle basic game-loop timing, and structure a mini state machine. Let us look at how to make this digital companion tick.
Which AI should I use for this?
Tickd is independent and not affiliated with any AI company.
The Anatomy of a Retro Handheld Toy
Before you start throwing prompts at Claude, you need to establish the architectural blueprint. A 90s virtual pet relies on three distinct layers:
- The Physical Chassis: The egg-shaped plastic body, the metallic button contacts, the keychain loop, and the subtle shadow casting on the casing.
- The Low-Res LCD Screen: A monochrome, slightly greenish-grey grid that displays 16x16 pixel animations, complete with top and bottom icon bars for navigation (Feed, Play, Clean, Sleep).
- The Game Loop and State Machine: A continuous background timer tracking the pet’s vital statistics (Hunger, Happiness, Energy, Hygiene) and updating the UI accordingly.
By keeping everything inside an SVG wrapper, we can scale the entire interface to any screen resolution without losing that crisp, sharp vector edge.
Step 1: Setting up the Master Prompt
Claude is incredibly skilled at generating SVG, but if you ask for a "virtual pet" without constraints, it will likely output a modern, glossy web app that looks like a SaaS dashboard. You must force the LLM into a strict aesthetic box.
Copy and adapt this initial system prompt to set the rules:
`text
Act as an expert frontend engineer specialising in retro UI emulation. Build a single-file, self-contained HTML page featuring a fictional 1990s-style virtual pet handheld toy.
Design Constraints: - Visual Style: The page must render a realistic, physical egg-shaped plastic toy in the centre of the screen. Use SVG for the physical chassis, button contacts, and LCD frame. The screen must have a distinct retro greenish-grey LCD glow with a faint pixel-grid overlay. - Screen Resolution: Emulate a 32x32 pixel matrix inside the SVG screen. Do not use an HTML canvas; build the pixels as dynamic SVG elements or use CSS grid mapping for that crisp, raw digital look. - UI Icons: Implement a row of classic icons along the top and bottom of the screen (a bowl for feeding, a ball for playing, a lightbulb for sleeping, etc.). Highlight these icons when the user selects them using the physical toy buttons. - The Creature: The pet itself must be an animated retro-style creature (e.g., a tiny pixelated dinosaur or alien). Provide at least three distinct animation states: idle (breathing/wiggling), eating, sleeping, and a sad/sick state. - Interactive Buttons: Render three circular physical buttons below the screen ("A" to select/cycle icons, "B" to execute/confirm, "C" to cancel/status check). These physical buttons must be clickable and drive the entire interface.
Combine all HTML, CSS (Tailwind allowed if needed, but inline SVG styles are preferred), and vanilla JS into one highly polished file. No external image assets or font libraries.
`
Step 2: Refining the State Machine
Once Claude delivers the initial render, the visual model will likely look decent, but the underlying game loop will need tuning. The logic needs to feel authentic. It should not be too easy to keep the pet alive, but it should not die within thirty seconds either.
Ask Claude to implement a tick-based state machine using the following variables:
- Hunger (0-100): Increases by 5 points every 30 seconds. If it reaches 80, the pet starts crying. At 100, the pet dies.
- Happiness (0-100): Decreases by 5 points every 45 seconds. Playing a mini-game restores it.
- Energy (0-100): Decreases slowly when awake. Must be restored by switching the screen lights off and letting the pet sleep.
- Hygiene (0-100): Every few minutes, the pet will leave a digital pixelated mess. If left uncleared, hygiene drops rapidly, causing illness.
To make this feel like a genuine piece of hardware, prompt Claude to structure the JS controller like this:
`javascript
const PetState = {
hunger: 20,
happiness: 80,
energy: 90,
hygiene: 100,
isSleeping: false,
isSick: false,
currentAction: 'idle',
tick() {
if (this.isSleeping) {
this.energy = Math.min(100, this.energy + 10);
this.hunger = Math.min(100, this.hunger + 2);
} else {
this.energy = Math.max(0, this.energy - 3);
this.hunger = Math.min(100, this.hunger + 4);
this.happiness = Math.max(0, this.happiness - 3);
}
this.checkHealth();
}
};
`
Step 3: Polishing the Pixel Graphics
If the rendering looks a bit too clean, Claude might have used modern anti-aliased SVG shapes for the pet. You want raw blocks.
Instruct Claude to construct the pet’s sprite sheet using raw SVG <rect> elements mapped to a coordinate system, or by using a CSS box-shadow pixel-art generator trick. The CSS box-shadow trick is incredibly clean for this: you can render an entire 16x16 pixel sprite using a single <div> with a massive, multi-layered box shadow.
Ask Claude: "Rewrite the pet rendering engine to use a CSS box-shadow pixel art array. This ensures every frame of the pixel dinosaur looks perfectly sharp and behaves like a genuine low-resolution LCD display."
Troubleshooting Render Anomalies
Sometimes, Claude will drop the closing tags on massive inline SVG structures, leading to a broken plastic shell or physical buttons that do not register clicks. If your virtual pet's plastic chassis is warped or the buttons do not align with the click targets, do not panic. Head over to our Claude troubleshooting hub to learn how to debug nested SVG parser limits and get your layout aligned perfectly.
Once your code is polished, load the HTML file in any browser, dim your office lights, and see if you can keep your digital companion alive longer than you did in 1997. If you want to push your prompting skills further before embarking on this build, check out our master prompt generator tool to refine your system instructions.
Keep going
Build something with the prompt generator, decode the jargon in the glossary, or compare the tools on our platform deep-dives.