Virtual Pet Prototype Sprites

This post is about the concept art and the initial software development for a portable virtual pet.

Because modern microcontrollers can do so much more than hardware used in virtual pets of the past, I'd like to see what I can make today. The goal is to have a creature that can run on common hardware - like an ESP32 or Arduino - and can make use of common display modules to show fun binary artwork.

It should have a way to receive user input, as well as possibly input from the environment. For example, besides buttons, it could have something simple like a photodiode to detect ambient light levels (acting like a skylight or window to the pet's world), a simple microphone to pick up ambient volume levels, or as complex as a LoRa, Bluetooth, or Wi-Fi radio to "see" nearby networks.

Ultimately it would be great to wear it on a watch, or carry it as a small self-contained trinket, or even as a small desktop toy.

Hardware

Development Board

I have been testing this project on an Arduino Nano, Arduino Mega 2560, and the Heltech WiFi Kit 32.

Displays

There are two common versions of the SSD1306 OLED module that I regularly see around and have on-hand: the 128x32 and 128x64 OLED modules.

A character on a 128x32 might look something like:

And on the 128x64 it might look like:

(The 128x64 modules I own have an orange/yellow color across the top 16 pixels.)

Because of the larger room allowing a better chance to show the character and its environment, I selected the 128x64 module. Also the orange bar makes a great location for UI or special interactions with the character below.

Sprite Concept Art

Character

After experimenting with a few different pixel art designs, this black cat silhouette-focused style of character stuck with me best. This little character felt really cute, expressive, and suitable for the 1-bit style.

Attitude:


Environment

Trying out ideas for icons and props that the character could interact with.


UI Concepts

Small font tests.

Virtual solar system concept.

Glitchmode.

Idle UI concepts.


Minigames

Memory testing game. Where the pet turns over half the cards, and the player turns over the other half. Trying to find matching pairs.

Maze game, where the player solves random mazes.

Golf for the player and the pet.

Laser pointer & mirrors. Cat scatters out the mirrors, player rotates them to bounce the lazer into the goal.

Greebles. Player controls the pet running through a halway, picking up snacks.

Platformer. Player controls the pet exploring different levels in a platformer.

Adventure. Player controls the pet exploring the neighborhood for adventures and interactions.

Snake clone: Worm

Gardening. Not sure what the mechanic is here, but growing food to sell and feed the pet.

Frogger-style clone.


Getting it onto the Arduino

The tool image2cpp (github link) is very useful in converting bitmap artwork into code to be used on microcontrollers. (The tool even works offline if you save the web page to a file, 10/10)

Once the bitmap is converted and stored in code, it can be drawn with a function call (for the Adafruit GFX library in this example):

display.drawBitmap(0, 0, (const unsigned char *) bitmap_image_data, 128, 64, SSD1306_WHITE);


Future Work

Breaking sprites down into parts

Memory is still limited with these microcontrollers. The Arduino nano, for example, runs an ATmega328 which has 2KB SRAM, 32KB Flash, and 1KB EEPROM.

The memory constraints place a limit on the number of character sprites I could include if I stored full poses, and less if I want to animate them.

It seems like it'll be necessary to build sprites out of smaller bitmap elements. For example, creating a sprite by combining a body shape, head shape, eye style, tail style, etc. This also would allow for animating different parts at different speeds, or playing different animations for individual body parts.

Character Behavior

It has not started yet, but there is a lot of work to be done building some sort of behavioral system for the character. My instinct is to reach for some finite state machines, with transitions influenced by things like hunger, rest, happiness, environmental inputs, etc.

Inputs

It will be important to build inputs for user interaction with the character (i.e., buttons). This is something I'd like to work on next. Even adding 2-3 buttons now would provide an ability to work on a UI and event system.

Hardware

Ultimately, instead of being an exposed Arduino board with loose wires hanging around, the goal is getting this built into a wearable/handheld item.

Published: April 22, 2022

Categories: arduino, gamedev