Week 7: Smashing Graphics

Sketch: https://editor.p5js.org/ryrotella/sketches/pyzh7sjFR

Trying to figure out how to add another canvas with CreateGraphics() was difficult. Eventually, I understood how to make it appear once, but how do I match up a new graphic with an object that I’m deleting? After a few hours, the answer laid in variables. I saved the last coordinates of a pumpkin before being destroyed and then told the program to play the gif on the graphic for a second. I compare the second the pumpkin got deleted with one second after in draw(). It works well, except with the second() function = 60 and goes back to 0. Any ideas on how to handle this edge case?

This is a pretty satisfying solution, but I would have liked to add sound to accompany the smashing. Is there a way to play sound files in P5?


Comments

Leave a comment