I want to have my sketch resolution be the same across different screen sizes. I have tried using PGraphics with image() but the performance suffers and my sketches frame rate drops. Am I using PGraphics and image() incorrectly / is there a better way to do this? I’ll post my code below.
Thanks for the response. I know that I can do relative sizing and have a windowed sketch with size(), but I want the sketch to be fullscreen with a letter-boxed area where the drawing happens with a fixed resolution.
I plan on adding more sketches to this sketchbook to make a top down shooter like game. If I made the sizing relative people with larger monitors would have more room to move around and would have an easier time dodging bullet patterns than someone on a smaller screen. I also don’t want to force players to play the game in windowed mode with no scaled fullscreen option.
I want it to keep its size, and have it be positioned in the center of the screen. In my sketch right now I have it so that the square where everything is being drawn will have borders on all sides.
If the canvas is always going to be 900 x 900, and you just want to move it to the center of the screen, you could just draw everything in one corner, then use translate(); to move it to the center.
P2D only makes the sketch faster by putting the quality of the sketch down, but a sketch of that scale shouldn’t drop the fps down to 10-30.
Translating would work well for centering, but if someone has a screen height or width less than 900px the canvas will be out of bounds. I would want the canvas to appear smaller to fit on the screen but behave like it were 900x900. If a person’s screen is really massive the canvas should appear larger, but behave like a 900x900 size. I don’t mind if the image appears a bit stretched.