Lag, fullScreen and anything you can think of

Hello There,

I’m new to processing and this forum, this is actually my first post. I’ve been using processing for a small project, a simple platformer with 4 levels. I’m aware that processing doesn’t specialize in game development but there are a few things I’d like to ask as a beginner now that I’ve finished making my game and I’ve been trying to improve it.

I’m using the default renderer as all of my objects / backgrounds are 2D images. All of the images move, at different speeds, when the player moves. The game runs fine but I’d like to improve the frame rate even more. I know this is hard to answer without providing my code but, what is the best way to accomplish this? It should be mentioned that whenever I draw an image I resize it and I calculate the image’s coordinates in each frame.

1 - To draw each image I just use the image(x, y, width, height) function. Should I avoid doing this? Most of the youtube tutorials I’ve watched use this way of printing stuff to the screen.

2 - Would making threads that calculate the images’ coordinates and test if there is collision with the objects help in any way? At the moment every single calculation is done by the one and only main thread.

3 - As far as I know, the default renderer doesn’t occupy the GPU. I think P2D does (which doesn’t work for my code) . Is there any way to occupy the GPU while using the default renderer? Would this even help my game run better?

4 - I made the mistake of writing the whole game with a 1440 x 900 window in mind, which unfortunately is a fixed size. While I do use the width and height variables in some parts of my code, whenever I try the game in full screen everything brakes (from a front end standpoint; back end is running as expected) . If I want to make my game run in full screen, do I have to change every single piece of code that uses fixed coordinates and image sizes or is there a simpler way? Maybe for example stretching my window to full screen but forcing it to “behave” like it’s a 1440 x 900 window, but I guess this would be too good to be true. Also, the game runs a lot worse in full screen, which is associated to my previous questions regarding lag.

Sorry for the long thread and the generalized questions. I can provide further explanation if needed. Any response to whichever of my questions is more than welcome. Thank you for your time!

2 Likes

You can use 3D mode to draw 2d and then for sure the GPU is used.
However then not all the drawing functionality is available and the coordinate system changes, like 0,0 is the center of the screen.
Using threads etc will take away time from game-play and art development which are actually the more important aspects. The code is only there to support telling a story, conveying a mood.
I think you could draw to a PImage sized 1440x900 and then stretch draw that to the screen @ widthxheight.

I think you could draw to a PImage sized 1440x900 and then stretch draw that to the screen @ widthxheight.

Do you know how to do this?