Who knew you could draw with a programming language? For someone who considers his actual drawing skills to be non-existent (read: stick figures), it’s been quite the discovery. We learned a couple of functions in class, including the arc() function – which, given the right parameters – bears a striking resemblance to Pac Man.
That was my starting point for our first assignment: draw something.
To draw Pac-Man, I used the arc() function and the fill() function to give him color. Pac-Man’s eye was drawn with the rect() function. The next step was to draw one of the ghosts. I decided to draw an oval shape with the ellipse() function and tried to “cut it” in half with rect() to create the shape of the ghost’s body. The eyes are drawn with more ellipse() functions, and the “legs” were created with the triangle() function, blocking parts of the body and blending with the black background.
Now, Pac-Man needs something to eat. Drawing the “food” was pretty simple: using the ellipse() function once again, this time in white.
The last step, or so I thought, was creating the borders for the level, as you would see in the game. To do this, I used the stroke() and line() functions, as well as the quad() and fill() functions.
At this point, I figured I might as well fill out the rest of the scene, with more “food” and three more ghosts.
Then I decided to change Pac-Man’s gender. Using rect() and triangle(), I drew Ms. Pac-Man’s facial features, and the bow she wears on her head. For the lipstick effect, I used ellipse(), and later arc() to block out the lipstick that wasn’t on her face.
And the cherry on top (pun pun pun): the iconic cherries from the original Pac-Man game, created with the ellipse(), stroke(), strokeWeight(), curve(), and rect() functions.
Click here for the sketch and the source code.