How to Make a Virtual Pet Game
A virtual pet is a small creature, a few meters and a clock. The art is in decay rates, readable moods and a reason to come back tomorrow that is a gift, not a guilt trip.

Key takeaways
- Store a timestamp, not a running timer. On every open, compute how much time passed and apply decay in one step.
- Clamp decay while the player is away so the pet is hungry, never dead, after a weekend off.
- Derive the mood from the needs and show it on the pet itself, with the meters as backup.
- Give a daily reason to return (a gift, a growth step, a new trick) that rewards visits rather than punishing absence.
To make a virtual pet game, give a creature three or four needs (hunger, happiness, energy, cleanliness) that drop slowly in real time, actions that refill them (feed, play, sleep, wash), a mood that comes from those needs and shows on the pet's face, and growth over days. The key technical idea is to save a timestamp and calculate decay when the player returns, rather than running a timer. The key design idea is to make coming back feel like visiting a friend, not paying a debt. Tamagotchi made pets die; most modern pet games do not, and players are happier for it.
Needs: three or four, each with a feel
Each need is a number from 0 to 100 with a decay rate and one or more actions that restore it. A good starting set:
- Hunger: drops about 4 points an hour. Feeding restores 30 to 50 depending on the food. Some foods are treats that boost happiness but barely fill hunger.
- Happiness: drops about 3 points an hour, faster when other needs are low. Playing a mini-game, petting or a toy restores it.
- Energy: drops while awake and active, refills while sleeping. Putting the pet to bed dims the screen and is its own small ritual.
- Cleanliness: drops slowly, faster after playing outside. Bath time is a chance for a cute animation.
With these rates, a pet left alone overnight wakes up hungry but fine, which is the point. Write rates in a small table so they are easy to tune, and put them on live Engine dials during testing. While tuning, a "time speed" dial that makes an hour pass in a minute saves a lot of waiting.
The time model: timestamps, not timers
A browser tab is closed most of the day, so the pet cannot live in a running timer. Instead:
- 01Save the needs and a "last updated" timestamp whenever something changes.
- 02When the game opens, compute the hours since last updated.
- 03Apply decay for that time in one step: hunger minus 4 times the hours, and so on.
- 04Clamp it. Never let a need fall below a floor (say 10) from absence alone. The pet is sad and hungry after three days, not gone.
- 05Apply any growth or events that should have happened while away (it is now day 4: the pet grew).
One caution: the device clock can be changed by the player. For a casual single-player pet this hardly matters. If you add leaderboards or trading, take the time from a server instead. Storing the pet in a database with sign-in also lets the same pet live on a phone and a laptop. User authentication explained covers the sign-in side of that.
Moods: show feelings, not numbers
Players should read the pet's state from the pet. Derive a mood from the needs with simple rules, in priority order:
- Sleepy if energy is below 20: droopy eyes, yawns.
- Hungry if hunger is below 30: looks at the food bowl, stomach rumble sound.
- Grubby if cleanliness is below 25: little stink lines, scratches itself.
- Bored if happiness is below 40: sighs, pushes its toy toward the player.
- Happy if everything is above 60: bounces, hums, follows the cursor or finger.
- Content otherwise: idle animations.
Each mood needs an expression and an idle animation. That is where personality lives. A pet with five well-animated moods feels more alive than one with twenty static ones. Keep meters on screen as backup, small and secondary, for players who like to see numbers.
A daily loop built on gifts, not guilt
Pet games live on daily return. There are two ways to get it. The guilty way: if you do not come back, your pet suffers or dies. The warm way: coming back is rewarded. The warm way keeps players longer and is kinder, especially for younger players. Improving retention covers the same daily-return habits for apps in general.
- Growth by days cared for: egg, baby, child, adult over about a week. Each stage looks different, so players anticipate the next.
- A daily gift: the pet found something (a shell, a flower, a coin) on each new day. Gifts can decorate its room.
- New tricks: after enough play, the pet learns to wave, spin or sing.
- A gentle streak: a count of days visited that does not reset harshly. Many games now allow a missed day or two before a streak breaks.
- A room to decorate: spend coins from mini-games on furniture and outfits.
Mini-games for playtime
Play is the deepest interaction, so give it two or three tiny mini-games of 30 to 60 seconds: catch falling fruit, a ball toss, a memory match with the pet's toys. Each raises happiness, costs energy and earns a few coins. Keep them simple and quick; they are a break inside the pet game, not the main event.
A virtual pet brief to paste
A virtual pet game for the browser, cute pastel style, works on phones in portrait. The pet is a small fluffy cloud creature that lives in a cozy room. Needs from 0 to 100: hunger (minus 4 per hour), happiness (minus 3 per hour, faster when others are low), energy (drops when awake, refills while asleep), cleanliness (minus 2 per hour). Actions: feed (3 foods, one a treat), play (two 45-second mini-games: catch falling berries, toss the ball), sleep (lights off), bath. Save needs with a last-updated timestamp; on open, apply decay for the time away but never below 10 from absence alone. Mood derived from needs with expressions and idle animations: sleepy, hungry, grubby, bored, happy, content. Grows from egg to baby to child to adult over 7 days cared for. A daily gift on each new day, a gentle visit streak that allows one missed day, coins from mini-games to buy furniture and hats. Small meters at the top, big pet in the middle. Soft sounds and an instant reaction to every tap. Put decay rates and a time speed multiplier on Engine dials. Save to the browser.
If kids will play it
Virtual pets are a favorite with children, so design with that in mind. No death, no punishing messages, no pressure to buy anything, no open chat with strangers. If you add accounts, collect as little personal data as possible. A free web game played from a link, without ads or purchases, is a lovely thing to build with or for a child. See how to make an educational game kids actually play for more on designing for young players.
Virtual pet mistakes
- Decay too fast. If the pet is miserable after two hours, it feels like a chore. Overnight should be fine.
- Only meters. If the only feedback is a bar, there is no pet. Animate the moods.
- Punishing absence. A dead or runaway pet after a busy week makes players quit for good.
- Nothing new after day 3. Plan growth stages, tricks and decorations for at least the first two weeks.
- Forgetting phones. Most pet players are on phones; big buttons and portrait layout first.
The pet's screens (the meters, the shop, the wardrobe) can be rearranged by hand in the UI Editor. When your creature is ready, publish it and share it in the Arcade. If your idea grows into a garden or farm the pet tends, the farming game guide covers crop timers and seasons.
Frequently asked questions
How do virtual pet games track time when closed?
They save a timestamp with the pet's needs. When the game opens again, it calculates the time that passed and applies the decay in one step.
Should a virtual pet be able to die?
Most modern pet games avoid it. Clamping needs at a floor while the player is away keeps the pet sad but safe, which keeps players coming back instead of quitting.
What needs should a virtual pet have?
Hunger, happiness, energy and cleanliness are a classic set. Three or four needs are enough; each should have its own action and animation.
How do I make players come back every day?
Reward visits: daily gifts, growth stages over days, new tricks, decorations and a forgiving streak. Rewarding return works better than punishing absence.

