I am developing a little game with p5.js in which I need to draw my own mouse cursor (for reasons that are not so important). Apart from the mouse cursor, the game has mostly static content and each frame consist of around 1-5 elements (images, basic shapes, text). At the moment, each frame is constantly redrawn.
I realized that the game is pretty CPU heavy, especially in Firefox. I already found out that this becomes (in my case) not better, when I use createGraphics() to create screens already during setup. The problem is not the creation of content, but the constant redrawing.
As far as my understanding goes (I’m very new to p5.js), when using a virtual mouse cursor as in my case, I have no choice to avoid constant redrawing, right? The virtual mouse cursor can be anywhere on the screen, can occlude any element and its position should be constantly updated. Or is there any trick I could pull?
edit: not sure if this is relevant, but the virtual mouse cursor uses requestPointerLock() and is moved according to movedX/movedY