This is a culminating project for the Block-based programming unit. This project simulates an electronic pet. It is happy if you play or tickle it. It is sad when you ignore it. It falls asleep if you ignore it for a long period of time and dies if you ignore it for too long. You don't have to take care of it when it sleeps. When the pet is born, its happiness level is at 100. When you play with it, its happiness level goes up. If you ignore it, its happiness level decreases.
Get Started
When the pet is born, it shows a loving face and says hello. The happiness level is set to 100 and he is awake. The sleep is set to zero.
Interactions
When I play with the pet by shaking the Microbit, it shows a surprised face and plays the giggle tune. Counter is set to zero.
When I tickle it by pressing the logo touch sensor, it shows a happy face and plays the happy tune. Counter is set to zero too.
When you turn the Micro Bit on, the happiness level goes to 100. When the Micro Bit is asleep, the happiness goes down by 1. You can put the bit to sleep by putting the screen down (sleep increased by 1).
As Time Goes On
The variable counter is used to keep track of time. It is incremented by 60 every second only when the pet is awake.
When It is Ignored
1. When we ignore the pet, it shows a sad face and plays a sad tune.
2. When we ignore it for a bit longer (30 seconds), it gets bored, shows a sleepy face and plays the yawn tune.
3. When we ignore it for too long (40 seconds), it dies. Once it dies, any interactions with the pet will not work.
Video of MicroPet