0

I've been coding a snake game, and I wanted to have a little html page for the instructions. But, I created p5 sprites for the buttons and I realized in the midst of the problem, I could not change the html page/web page through the p5 JavaScript editor. Is there a way I could change the webpage based on a p5 function?

So I tried creating an html element, but then I realized I couldn't make it go away if the game changed, e.g. the gameState changed from 0 to 1. When I tried it, it stayed there. Though I am still in the midst of finishing the game, is there a way I could call an html file to change using a p5 editor function? At this point, you might just call it changing to a different webpage. I don't know any methods to, and when I search online, I find nothing.

  • 1
    You don't need a p5.js specific function, just use a built in JavaScript method [How do I redirect to another webpage?](https://stackoverflow.com/questions/503093/how-do-i-redirect-to-another-webpage) – Samathingamajig Mar 27 '22 at 03:31
  • Please provide enough code so others can better understand or reproduce the problem. – Community Mar 27 '22 at 06:10
  • 1
    Thanks @Samathingamajig ! I'll try that and see if it works! Update: worked like a charm! – getrektnoob123 Mar 27 '22 at 15:28

0 Answers0