The little pet is capable of eating, getting agitated, playing a game, and yes, even pooping…
All of the audio and artwork assets are included and easily replaceable for those who want to create their own pet.
The source code is fully open source and published under the MIT license. Although I built this specific to my badge hardware, it could easily be ported to other hardware with a SH1106 or SD1306 display and 3 buttons. See my GitHub for the code.
If you want to modify the code, some basic guidelines are below:
- VirtualPet/lib/VirtualPetGame.py is the main game class file. Modify the code here to add new or change existing behaviors, change the mini game, or change the menu entries
- VirtualPet/lib/VirtualPet.py is the class file for the pet. This file contains variables for things like hunger rate, happiness rate, etc and some basic logic for pet lifecycle
- VirtualPet/assets is the directory that contains all of the game screens and audio files. All of the screens are mono-color graphics encoded in 1/0 format. The screens can be swapped out by drawing new pixel art on http://www.pixilart.com and then uploading them to https://www.dcode.fr/binary-image to do the 1/0 conversion.
- The audio files must follow CircuitPython audio file guidelines (PCM 16-bit Mono WAV file 22-kHz sample rate). See this Adafruit guide on how to convert your audio files