We enjoyed Dave Astel's CircuitPython Choose your Own Adventure guide - but it required a PyPortal to tap the buttons on the display. We wanted to play PYOA games on our PyBadge/PyGamer, so we added CursorControl to PYOA framework to let you click the buttons instead of tapping them.
If you want to use PYOA on your PyBadge/PyGamer, follow along below!
Before you get started, you'll want to prepare your PyBadge/PyGamer with the required libraries to build a choose your own adventure game:
- Follow the steps listed on this page and come back here when you've followed them.
Code Setup
Clicking on download Project zip below will give you a zip file that you will need to dig into to get the cave directory. Copy this directory to your CIRCUITPY drive.
[ { "card_id": "start", "background_image": "page01.bmp", "text": "Welcome adventurer. Your adventure begins, as many do, in Ye Olde Inn.", "text_color": "0x000001", "button01_text": "Continue", "button01_goto_card_id": "inn" }, { "card_id": "inn", "background_image": "page01.bmp", "sound": "pub.wav", "sound_repeat": "True", "text": "This is a peaceful, happy inn with plentiful drink, tasty food, and friendly staff.", "text_color": "0x000001", "button01_text": "Stay", "button01_goto_card_id": "inn", "button02_text": "Go!", "button02_goto_card_id": "cave entrance" }, { "card_id": "cave entrance", "background_image": "page01.bmp", "text": "There is a dark cave in the hillside before you.", "text_color": "0x000001", "sound": "cave.wav", "sound_repeat": "True", "button01_text": "Enter", "button01_goto_card_id": "entry", "button02_text": "Run", "button02_goto_card_id": "inn" }, { "card_id": "entry", "background_image": "page01.bmp", "sound": "cave.wav", "sound_repeat": "True", "text": "You are in a dark, narrow tunnel.", "text_color": "0x000001", "button01_text": "Next", "button01_goto_card_id": "side opening" }, { "card_id": "side opening", "background_image": "page01.bmp", "sound": "cave.wav", "sound_repeat": "True", "text": "You are in a small room, one tunnel leads ahead and another to the side. Do you continue on or explore the side tunnel?", "text_color": "0x000001", "button01_text": "Continue", "button01_goto_card_id": "skeleton room", "button02_text": "Side T.", "button02_goto_card_id": "treasure room" }, { "card_id": "treasure room", "background_image": "page01.bmp", "sound": "cave.wav", "sound_repeat": "True", "text": "There is a pile of treasure here. Congratulations!", "text_color": "0x000001", "button01_text": "Next", "button01_goto_card_id": "maze 1" }, { "card_id": "skeleton room", "background_image": "page01.bmp", "sound": "cave.wav", "sound_repeat": "True", "text": "There is a skeleton on the floor. From the items around it, it seems to be that of an unfortunate adventurer.", "text_color": "0x000001", "button01_text": "Next", "button01_goto_card_id": "maze 2" }, { "card_id": "maze 1", "background_image": "page01.bmp", "sound": "cave.wav", "sound_repeat": "True", "text": "There are passages to the left and right.", "text_color": "0x000001", "button01_text": "Left", "button01_goto_card_id": "maze 3", "button02_text": "Right", "button02_goto_card_id": "maze 2", }, { "card_id": "maze 2", "background_image": "page01.bmp", "sound": "cave.wav", "sound_repeat": "True", "text": "There are passages to the left and right.", "text_color": "0x000001", "button01_text": "Left", "button01_goto_card_id": "maze 1", "button02_text": "Right", "button02_goto_card_id": "maze 4" }, { "card_id": "maze 3", "background_image": "page01.bmp", "sound": "cave.wav", "sound_repeat": "True", "text": "There are passages to the left and right.", "text_color": "0x000001", "button01_text": "Left", "button01_goto_card_id": "maze 5", "button02_text": "Right", "button02_goto_card_id": "maze 2" }, { "card_id": "maze 4", "background_image": "page01.bmp", "sound": "cave.wav", "sound_repeat": "True", "text": "There are passages to the left and right.", "text_color": "0x000001", "button01_text": "Left", "button01_goto_card_id": "maze 1", "button02_text": "Right", "button02_goto_card_id": "maze 6" }, { "card_id": "maze 5", "background_image": "page01.bmp", "sound": "cave.wav", "sound_repeat": "True", "text": "There are passages to the left and right.", "text_color": "0x000001", "button01_text": "Left", "button01_goto_card_id": "maze 4", "button02_text": "Right", "button02_goto_card_id": "creaking" }, { "card_id": "maze 6", "background_image": "page01.bmp", "sound": "cave.wav", "sound_repeat": "True", "text": "There are passages to the left and right.", "text_color": "0x000001", "button01_text": "Left", "button01_goto_card_id": "creaking", "button02_text": "Right", "button02_goto_card_id": "maze 3" }, { "card_id": "creaking", "background_image": "page01.bmp", "sound": "creak.wav", "sound_repeat": "True", "text": "You hear an ominuous creaking from around the corner", "text_color": "0x000001", "button01_text": "Cont.", "button01_goto_card_id": "bridge room 1", "button02_text": "Go back", "button02_goto_card_id": "inn" }, { "card_id": "bridge room 1", "background_image": "page01.bmp", "sound": "creak.wav", "sound_repeat": "True", "text": "There is a creaking, rickity wooded bridge leading across a gaping chasm.", "text_color": "0x000001", "button01_text": "Cont.", "button01_goto_card_id": "bridge room 2" }, { "card_id": "bridge room 2", "background_image": "page01.bmp", "sound": "creak.wav", "sound_repeat": "True", "text": "At the other end is a large treasure chest. There is also a short tunnel with daylight at the end.", "text_color": "0x000001", "button01_text": "Treasure!", "button01_goto_card_id": "die", "button02_text": "Leave", "button02_goto_card_id": "inn" }, { "card_id": "die", "background_image": "page01.bmp", "sound": "scream.wav", "text": "The bridge gives way and you fall to a painful death.", "text_color": "0x000001", "button01_text": "Next", "button01_goto_card_id": "inn" } ]
In the code.py
file on your device, set the example as the cave example. You can do this by changing the following line from:
gfx.load_game("/cyoa")
to
gfx.load_game("/cave")
Your PyGamer/PyBadge will automatically load the cave game and create a cursor overlay. You can move the cursor around using the joystick on the PyGamer or the D-Pad buttons on the PyBadge.
To click the buttons on the display, press the A button. This is the same button for both the PyBadge and the PyGamer.
That's it! If you would like to try your hand at designing or writing your own adventure game, check out this page on Dave Astel's guide.
Page last edited January 22, 2025
Text editor powered by tinymce.