For the midterm project, I did a platform game named. The complete code and all resources can be found here.
This game is for 2 players. The goal is to go through “trials”, collect crystals, and get to the airplane to fly away as soon as possible. There is a small problem – you only have 60 seconds.
I wanted to try to create a game myself, similar to the one I played as a child. I always liked the opportunity to play with a friend at the same time, so I decided to add this opportunity to my game.
For this game, I created several classes: 2 character classes, a platform class, a platform class that cannot be stepped on aka platform enemies, a timer class, an airplane class, and a crystal class. Use the A, W, D keys to move Player 2 and the arrow keys to move Player 1.
1. It was not easy to create interaction between the character and the rest of the classes – for the game to be interactive, the player must see everything that his actions in the game lead to. I spent a lot of time trying to figure out what kind of response should follow from the game to various interactions, whether this is a “game over” window or, on the contrary, congratulations on winning.
2. It took time to figure out what the distance will be between the objects at the moment of collision and from which side. It was even harder to understand when the picture of the character was in relation to the center, not the edge.
3. For the crystal to disappear when the character touches it, I had to try several options and go through dozens of “null pointer exception” errors. I am pleased with the result, where the crystals are neatly collected in the corner of the screen.
4. Having two players in parallel is not easy: it was necessary to understand the key pressed and released functions, and also not to get confused with them later. Because I named some variables the same for different classes, the character of the second player did not want to appear for a long time.
There is no limit to perfection, and you can modify the game indefinitely. I already have dozens of ideas on how I will improve this game in the future, from a progress bar to numerous levels. However, I am happy with how this game has turned out for me at the moment.
While writing the code for this assignment, I have used all the knowledge gained from the last 6 weeks and I have a certain sense of satisfaction with the result. Also, coding is very time-consuming, and it’s best to start as early as possible.