Pong is one of the first video games ever made. A simple, but very fun sport game where the objective to hit the ball back and forth. The other game was Battleship; a strategy game designed with 10×10 grid where you place ships and aim to destroy the enemy’s ships. In this project we were asked to code a game using MATLAB. We will use our peers to help test our codes so we can have a fun game for people to play and enjoy.
To code pong, we had to research multiple different aspects of the game. First, we needed to figure out the correct velocity of the ball as it increases in speed as the game continues. Next, we needed to decide at which angle the ball should return as it hits a paddle. Finally, we had to make sure the ball would correctly return by using if-statements so the ball will not pass certain x,y coordinates. In order to solve these problems, we would use other codes of the game to test which velocities and angles of return would be ideal for our game. The final design was a level system that increased difficulty as you accumulated points. A point was rewarded each time you hit the ball back, and at a score of 10 the speed would then increase. A few errors we ran into were that the game would be that it would freeze after a couple seconds of running it, but we were able to fix it by setting time to zero and initiating the loop. Another major error was after adding the level system, the ball would return the ball even if the paddle was not accurately placed. This error was fixed through using MATLAB help pages along with communication amongst our team. How we could improve our game would be by adding a multiplayer option, so you do not have to go against a computer.
For Battleship, we began by creating a difficulty range from level 1 to 3 to give the computer a higher probability of hitting your ships as the difficulty increased. Two established rules of this game are that the ships cannot exceed the 10×10 grid, nor can they be overlapped. After you set the difficulty, then you place you ships in whatever strategic order you please. After that, you begin to play! As you play, if you hit an enemy boat there will be a red mark displayed, if you were to miss there would instead be a white mark. To create a smooth gameplay, we used if statements to reduce any overlapping errors which could detriment gameplay. Most issues were easily solved by talking amongst our group and online tools. What we would do to improve our game would be by creating our own models to further improve our games design visually.
In the end, we were able to successfully create two games that are fun and simple. By using our teammates and help online, we were able to debug our games and create a smooth gameplay for our group and peers who may play. We coded bots that would play against us, but if able we would like to incorporate a multiplayer system in the future.