Hi all,
Programming uber-beginner here. Having a bit of trouble figuring out one (of many) problem(s) with a current small-scale game project: https://editor.p5js.org/jakobfree/sketches/B09u80zKh
I’m trying to create a sprite (“lava”) that floats across the screen of my sketch and does a few things:
- if it flies off the screen, it returns to its origin point (“volcano”)
- if it hits a specific type of other sprite (“jungle”), it decreases the overall score in the game
- if the player hits it with his/her avatar (“islandgod”) the lava sprite is destroyed (using remove) and then the sprite…
3.5) …will respawn at its origin point to start the process all over again
Right now I’ve got 1-3 working pretty well, but as soon as I use the remove method in p5 play, the sprite is removed permanently, and try as I might I cannot get it back. Now, I know that remove may not be the best solution to my problem, but I’m not sure what else to to do here.
Here’s the code I am using to destroy the sprite:
islandgod.overlap(lava, stopLava);
function stopLava(islandgod, lava) {
lava.remove();
}
It may be best to just check the sketch out directly. Please let me know if there is any additional info I can supply. Thanks!