Make a game using Classes

Krischankramer
1 min readMar 9, 2021

For this week's assignment, I created a version of the game pong. In order to do this, I used variables to define the balls' random placement when the code is originally launched. I then set up the canvas and background and defined a paddle class that drew the rectangle and allowed it to move with mouseX. There is also a score counter that adds up each time the ball hits the paddle. The hardest part was adding the bounce to the ball when it comes into contact with a border or the paddle and figuring out how to make the movement random when it hit the paddle. I wasn’t able to add the art into the game because I was planning on replacing the ball and rectangle I was struggling to make it work. The game took me a while to even get running because I was having a lot of issues and struggles using classes to define the various elements that were involved. However, and to my surprise, I was to create a version that involved lasses that didn’t absolutely drive me insane. So although I kind of defaulted to something I could manage better, I'm still happy to have a functional product.

--

--