Final Exam Project
- colleenguirand1
- Dec 9, 2021
- 1 min read
Originally, I was planning on creating a doodle jump game where the player presses the space key to make an object jump from platform to platform, but I didn't seem to figure out how to make the object jump once it landed on a platform, so I created a game of catch.
First, I created multiple variable; screen, y, x, speed and score. Screen essentially lets the p5 know that nothing should be occurring. Y and X is used for measurement purposes of the ellipse and score is to keep track of the amount of times the ellipse comes into contact with the moveable square.
Secondly, I created a draw function basically saying that if the screen is false make gameOn true, which initiates the game play. Then the gameOn function keeps track of the score, parameters of the ball and the use of RectMode for the rectangle. I set y += to speed then said if y is greater than the height of the canvas make the screen equal to 1.
Then, I made conditionals for the movement of the mouse when the rectangle hits the ball. When the ball collides with the rectangle, the score would go up by one. In order to get the balls to drop at random, I used the pickRandom to have them coming down from the canvas.
https://editor.p5js.org/cguiran1/sketches/NyNHZtaIs
Comments