Midterm Game
- danielgrinchenko
- Oct 27, 2020
- 2 min read
For my midterm project I decided to code a 1v1 hockey game. I first had the idea to make a simple story mode game where the player picks his story and each choice he makes decides other choices in the future. But I decided that it would be easier and more fun to make a hockey game. I first started with the player controls. I made two classes, one for each player, and set the variables in the constructors. I wanted the players to move using the arrow keys and the 'wasd' keys so I did that in the move functions. I also created display functions and made the player objects to see if my code worked correctly, and it did. I then drew the hockey rink and the goals and made it so the players could not leave the rink. I then proceeded to add a puck class. I added move and display functions to make the puck work. I added bounds so the puck couldn't leave the rink and I made it so the puck bounced off the walls and goals. My first struggle occurred when I had to make the puck interact with the players. It took some time, and some help, but I managed to make it so the puck bounces of the players, goals and walls. Now the big thing that was left was to make the puck enter a goal and have it register as a goal. This was pretty simple. I made it so that every time a player scored a goal it would bring up a new screen, a new gameState, to a winning screen. If the 'r' key was pressed then the game would reset and restart. Lastly, I added accents to make it resemble an actual hockey rink and added my favorite teams logo to the center of the rink.
Here is a link to my code: https://editor.p5js.org/Grinchenko/sketches/8QSi71zmc
Comments