Inspiration
I used to play Mortal Kombat all the time as I grew up. I thought it would be fun to recreate it in a simple yet fun way!
What it does
To fight your opponent, you must select one of three attack types and answer a math problem to deal damage to your opponent. If you get the answer right, you’ll deal that amount of damage. If you get it wrong, your opponent will deal that much damage to you!
How I built it
I made objects of each character so it would be easy to store various attributes and actions. I made a class for the character and stored the interface in a header file. The implementation of the class's member functions and variables is stored in another .cpp file. The main file handles the main execution of the code. Most of the error handling is done by loops and if-statements.
Challenges we ran into
The first challenge I ran into was making sure the user input works. There were several ways to handle it but I had to consider how a reference would be lost outside of any if, while, etc statement. Another challenge was handling the logic of my code. It is really easy to mess up a small calculation that prevents the whole game from functioning normally.
Accomplishments that I'm proud of
First and foremost, I am proud of my first hackathon participation. It wasn't as complicated as I thought it would be but it felt rewarding to make something. Another thing I feel accomplished about is how I was able to bring an idea I didn't think would work into a fully functioning project. Although I had bigger plans, I'm happy with my progress so far.
What I learned
I learned that testing my code is more important than writing it. There were a lot of bugs I had to fix while debugging and sometimes finding the solution wasn't easy. Coming back to my code with an open mind definitely helped alleviate some of the stress to make sure it worked.
What's next for Math Mortal Kombat
The next step is making the code more concise. There are a lot of parts I can condense to make the project much more efficient. For example, one of the benefits of object-oriented programming is reusability. Instead of making separate objects for each character, I could have declared the same object twice. Originally, I had big ambitions of adding more characters and attributes so I would fulfill those as a next step as well.
Log in or sign up for Devpost to join the conversation.