Homework 7: Game with Classes

Esther Barnett
2 min readMar 7, 2021

For this assignment, I upgraded last week's smile-catching game with the use of classes.

Here is my new game:

I used two classes, scoring, and editable face. The scoring class includes the variables numEaten and numMissed to represent the numerical value that is associated with how the player catches the smiley faces. the method ateIt adds one to the original variable numEaten and the method leftIt adds one to the variable numMissed. In order to calculate the total score, the method toString was utilized to first display the text of all the individual scores as well as subtract the number of times the player missed from the times they caught a smiley. This creates the total score displayed in caps. My second class is named EditableFace and it determines which face appears after the player either catches or misses a smiley. Because the functions for both the main part of the smiley faces are similar, two separate methods were created for the arcs used arcs the happy or sad expressions. These are utilized in the global variable editableFace which indicates if it is a smiley (true) or is a frown (false).

My inspiration stemmed from the same game and art pieces as last week:

I also used inspiration from the game Rotate and Roll, as the faces change based on the movement and choices of the player:

I also used the same idea of the Pacman ball:

editor.p5js.org

--

--