What You Will Build
Create an interactive companion sprite with needs, moods and responses to your actions. Follow the guide below to build the project, then open the official Raspberry Pi page for starter files, worked examples and extra help.
🍓 This project is on the Raspberry Pi Foundation website. Click the orange button above to access the full guide, starter Scratch project and extension activities on projects.raspberrypi.org.
What You Will Learn
- Use variables to track a companion's needs over time
- Switch costumes to show different emotional states
- Create interactive buttons for feeding, playing and sleeping
- Implement a real-time needs system with a forever loop
- Add a critical alert when a need reaches zero
Step-by-Step Guide
- 1Add a cute character sprite with at least 3 costumes: happy, sad, neutral.
- 2Create 3 variables: hunger, happiness, energy — all set to 5 on start.
- 3Add a forever loop: every 5 seconds, decrease hunger by 1.
- 4If any stat < 3: switch to sad costume. If all stats > 6: switch to happy. Otherwise neutral.
- 5Add a Feed button sprite: when clicked, change hunger by 2 and play a happy sound.
- 6Add a Play button: change happiness by 2, change energy by -1.
- 7Add a Sleep button: change energy by 3, wait 3 secs (sleeping animation).
- 8If any stat = 0: flash display and play alarm sound — critical alert!
- 9Add a name variable — ask for it on start and use it in greetings.
- 10Cap all stats at 10 using if stat > 10 set stat to 10.
Extension Challenges
Finished the main project? Push further:
- Add a random event every 30 seconds — the companion gets cold or bored unexpectedly.
- Add a health bar that shows the total of all three stats as a progress display.
- Add a day counter that shows how many 60-second cycles the companion has survived.