Inspiration

I wanted to help people learn, in an engaging way, about the specific medical procedures and decisions doctors have to take every day, in order to save their patients. The inspiration for my styling came from 1990's arcade games, because their styles would always catch my attention and would keep me immersed.

What it does

FLATLINE is a medical simulation/game that teaches its players to solve realistic patient cases by giving them the ability to run medical tests and select diagnoses. Firstly, the system generates a patient profile, symptoms, and a specific illness (which is hidden from the player) using Gemini 2.5 Flash. Then, it gives the player a dynamic list of 6 medical tests to choose from, in order to uncover the patient's other hidden symptoms and their illness. Lastly, the patient is required to select a diagnosis after each test (the 6 test and diagnosis options are generated by Gemini 2.5 flash as well). A correct match will save the patient, while an incorrect one will lower the patient's vitality and make their condition worse. If the player makes too many wrong diagnoses, the patient may just flatline.

How I built it

I used a modern Full-Stack architecture, in order to build this project. For the frontend, I used JavaScript, React (Vite) , HTML, and Tailwind CSS, in order to simulate CRT monitor effects and scanlines. For the backend, I used Python, FastAPI, RestAPI, and Pydantic, in order to successfully convert the generative AI's (Google Gemini API, model: 2.5 Flash) responses into usable JSON for the game's logic.

Challenges I ran into

The biggest challenge I ran into was ensuring that Gemini 2.5 Flash returned valid JSON without conversational filler. I solved this with a regex-based clean_and_parse_json utility to format the output correctly for the python backend. Astonishingly, creating a seamless background EKG pulse was kind of difficult as well. Since, the line would jump and disconnect when the animation tried to loop in the background. Thankfully, I fixed this by rendering two identical SVG segments side-by-side and sliding them infinitely.

Accomplishments that I'm proud of

I am proud of finding a way to structure Gemini 2.5 Flash's responses into a structured, playable loop. Since, this was the first time I attempted getting an LLM to consistently output valid JSON and using it for most of a game's logic. Additionally, I am proud of this project's visual aesthetics as well. As, implementing the CRT scanlines, text glow, and the infinite-scroll EKG animation gave the project the immersive feeling that I had envisioned.

What I learned

Building FLATLINE taught me that you don't need to implement complex 3-D graphics, in order to make an idea feel immersive. Moreover, it also taught me the different ways I can make a generalized LLM an "Agent" that upholds and maintains a game's logic.

What's next for FLATLINE

In the future, I want to introduce a budgeting system within the game that assigns certain costs to the the tests, in order to increase its complexity/difficulty and make it more realistic. I also want to implement a database that saves the player's cases, allowing them to review their past mistakes and keep a track of their success rate.

Built With

Share this project:

Updates