DEV Community

Amanda H
Amanda H

Posted on

I Made an RPG Game in Python For The First Time

Building and coding an RPG game, or any video game in general for that matter, felt like a dream to me a few months back. I have played all sorts of video games since I was little, but none of those games gave me the euphoria that creating this game made me feel. Benji's Escape honestly gave me the boost that I needed in regards to feeling like a legitimate programmer (a beginner one at least) and being able to understand the process of building a text-based game in the terminal.

Benji's Escape is a story based on my pet bearded dragon, Benji, who I love and have had for 3 years at this moment in time. You play as Benji, a young but determined bearded dragon that was just adopted by a loving family and realize that the son, a 6 year old named Timothy, is your new owner and essentially has no idea what he's doing or how to take care of you (fun fact: bearded dragons require very specific needs that need to be known before you buy one!). Your goal is to follow the story, fight each member of the family in their home, and escape off into the wild and finally be free or risk being taken back to your tank to most likely meet a horrible fate.

Benji has his own class with name and health attributes, along with methods that give him actions like bite, run, and scratch. Each enemy that he faces (Timothy, Mom, and Dad) have their own attributes stored in their own dictionaries, and this information along with the Benji's class information are passed into each fighting function that occurs. The story progresses with functions that either follow one another or are triggered from within another function, each one being carefully placed so that the sequence of events are correct. When you battle one of the family members, you are given the options that are within the methods of the Benji class and the user must type in the action. The attack damage is randomly generated and decrements the health in a turn-based battle style between you (Benji) and the enemy you are facing. If your health goes to zero, then it's game over, but can play again if you like; if the enemy's health goes to zero, then the story continues. When you beat all 3 enemies, you officially win the game and a screen pops up asking you if you'd like to play again or quit. You can also quit at any point in time, whether it be during battle or at the title screen.

Thankfully I managed to fix a multitude of bugs as I built this game and finished it to my liking, but it definitely wasn't easy. The most difficult parts about Benji's Escape were the game logic and trying to make the code more efficient in terms of not having so much repetition. On the last day before this project had to be completed, I discovered a bug as I did the final test run and simply could not leave it there, and ended up becoming a whirlwind of a night because of it. The game logic that I created took hours upon hours of writing out and breaking down my thoughts, typing it up, testing it, then rinse and repeat. Despite the hardships, the bug actually allowed me to cut out some unnecessary code and made it more presentable, which I think helped me improve my debugging skills.

Honestly, I don't think that I've ever been this proud of something before. I've always wanted to make a video game as a bucket list goal and now I can finally say that I've made one! Whenever I solved a problem dealing with the game logic or getting the story to line up the way that I wanted it to, it was so exciting and made me feel more accomplished than ever before. Even Benji ran through the final test with me and he loved it(at least I think he did)!

There of course were additional features that I wanted to add, but simply couldn't because of the lack of time. If I could continue working on this project, I probably would have added more choices in decision making prompts, adding different effects for choosing an action in battle depending on who you're facing, and adding an end credits after you escape that scrolls upwards. I also would have refactored the code further so that I could find a way to make the code shorter. Who knows, maybe I will come back to this one and improve it later on!

Benji's Escape, if you'd like to try it out for yourself, is in my github repository. I hope you enjoy it just as much as I enjoyed making it!

Top comments (0)