Inspiration
This project was inspired by Tamagotchi, a Japanese handheld digital pet toy in an egg-shaped case that was popular in the early 2000s. It had an interface involving 3 buttons and a screen interface, which we reflected in our UI design.
What it does
The interface shows a Petr moving around at random, with 3 bars above it representing its hunger, entertainment, and cleanliness at the top, and 3 icons representing buttons to feed, play with, and bathe the Petrgotchi which increase or decrease the aforementioned values in respective bars. If any of the values reach zero, then the Petrgotchi becomes dead, sad, or stinky respectively, depending on which one reaches zero. The values passively decrease at varying rates, so the user has to make sure all the bars are topped up.
How we built it
This project was built entirely using Python. We started by writing the backend code: a Petrgotchi class which contains its basic attributes, behaviors and logic to change the behaviour values with respect to click and time. Once that was implemented, we started to look towards options for the frontend user interface, tried building a web game using Flask and JavaScript but faced blockers, and eventually settled on using the Pygame library to implement this.
Challenges we ran into
Before using Pygame, we attempted to implement the game with a combination of Javascript and HTML on a server of Python Flask, using ngrok to host it. However, having spent more than half the time, we ran into issues with connecting the front-end code with the backend as the Python library we were using to do so, Flask, was not compatible with the library we were using to implement the event loop in the backend, asyncio. We were able to finally implement the GET and POST requests, but the web game hung up and became unresponsive intermittently. While two of us attempted to work around this issue, the other two began exploring other options, primarily Pygame, which ended up being our final product as that was accomplished before the workaround for the Javascript implementation was.
Accomplishments that we're proud of
All of our group was primarily only familiar with Python, or heavily preferred it over other languages, so we're very proud of the work we were able to accomplish using Javascript, even thought it was eventually scrapped. It was also all of our first times using the Pygame library, so the fact that we were able to finish an entire rewrite of the user interface with it in the last hours of the hackathon using the library was also a major accomplishment.
What we learned
We learned a lot about writing code for web development, particularly the interactions between front and back end code, as well as interactions between different languages, even though that implementation didn't pan out. Furthermore, our experience stressed the importance of checking all of one's options for implementation. We also spent a significant amount of time learning about git - the hard way.
What's next for Petrgotchi
Near the end of the time limit, we found an API that is actually compatible with asyncio called aiohttp. We plan on finishing the web implementation of Petrgotchi, while also finishing the PyGame version.
Log in or sign up for Devpost to join the conversation.