Some notes before the main part of this note: This is a Maker project from a few years ago and original post is from https://dev.to/whykay/my-maker-project-print-your-own-adventure-game-38fa
I recently resurrected this project to give as a lightning talk at PyLadies Dublin's 10th Anniversary meetup on Tue Oct 10, 2023.
When I was working on this project as Maker Advocate for Dublin Maker, it was meant to be ready for Berlin Makerfaire 2020, but it was cancelled due to Covid. But finished the project anyway for that date, and since then I heard Berlin Makerfaire is no more and has moved south of the country. 😟
Future goal is to port this from Pi-top4 to Raspberry Pi Pico and make it more self-contained.
Anyway, here we go, I hope you enjoy this.
What is this project? Print your own adventure game with a thermal printer, Raspberry Pi, arcade buttons and CircuitPython.
Why am I doing this? When I was the Maker Advocate (Dublin Maker), it was a way to extend my knowledge in this area, always a fan and huge awareness, but always more of a spectator and supporter than active Maker of physical projects. Plus it's fun to try new things.
Well, I can say I am rusty as heck, but I needed the coding to while away the time. My goal was to complete my Maker project that was meant for Berlin Makerfaire in the next couple of weeks, but that has been cancelled due to COVID-19.
So I mustered my energy, blew the dust off the coding side of my brain and pulled out all my electronics bits and latest code from my repo. It was a working prototype on a given sample of a dummy data for the thermal printer to print out your text based adventure game.
So it was shock, horror and no surprise when I went to refactor the code, I was thinking... "What was I doing?!? Omgerd!"
The next part of the project was pretty straight forward, fix up the JSON to be read into the code so printer will work. With this new code, I'm no-where having it connected up with the electronics (I already know it worked from last time I was prototyping).
So to get this JSON file, I want to have a way I can add stories, so into a spreadsheet it goes, I export it to CSV file and this CSV file gets read in by the new CSV to JSON convertor I wrote in Python. Now it's a library I can use for my main project, yippee.
💡 Found this story/prompt generator handy for what I'm doing as I can't seem to think of anything story to write: https://www.plot-generator.org.uk/
I took it for granted. I spent a whole day wrangling code and ended up going to bed late as I was so close to what I wanted. I was going to try using Pandas instead of the general csv, itertools and groupby. Turns out when I got up the next morning, I was overthinking the problem and refactored (again). Didn't have to use Pandas (now I know a little about it), normal plain Python in-built tools was a-okay. 🙌
Also wrote tests (using PyTest) to make sure the data and JSON format is correct, and tested a sample run through of a game. Well, that was easier than expected and it worked. 🙌🙌
This is the project by the way, an early prototype (with Pi-top 3, I have a Raspberry Pi 3 in it) is pictured below...