• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Frame Rate Issues

B

blutzauger

Guest
Hi guys. My first time posting here in the new forums. My question is rather generic. From the top of your head, can you list reasons on why sudden drops in frame rate in a game can occur? You see, I'm in the middle of crafting my original pixel-graphic JRPG. My goal in here is to create a game that can be played even with a low-end PC or laptop. I am creating my JRPG in a rather good PC but I am testing in a very low-end laptop with only 448mb RAM and 32mb VRAM. So far, thankfully, I am maintaining a consistent 60FPS with the low-end laptop. So the question is what pitfalls should I be avoiding. So far, I am maintaining this policy of limiting instance count to only 500. How about yours? Thanks.
 
A

Aura

Guest
Depends a lot on your game and how you're handling and programming it. I'd personally suggest using the profiler to find out what your game is slowing down due to then you can take actions accordingly. Also, 500 unnecessary instances active at the same time might slow down your game, so you'll want to deactivate the instances outside the view and reactivate them once they are back in.
 

Phil Strahl

Member
As @Aura already mentioned, the profiler really is a great tool in identifying bottlenecks in your code. Further, low hanging fruits for optimization are always the Draw events (at least in my case): Try to keep them as clean as possible, meaning doing all necessary lookups and calculations before the draw event and just read values from there. Another thing you might want to avoid is creating and destroying a lot of instances each frame which might be the case when visual effects are involved. And then there are iterations through large lists or arrays on each frame, because everything needs to wait for that loop in question to finish first.
 
M

Misty

Guest
Use rooms. Dont put all enemies in one giant world map, but divide it into rooms. Divide your world into forest, lake, and summer zones. But then in each zone, have different sub-zones like tree-house or pond sector and what not.
Then, when it's all said and done, use YYC compiler.
 

RangerX

Member
I'd keep the number of active objects MUCH lower personally. I'd say under 100. If you have more than that in a retro-style JRPG I question how you're doing things.
Other general stuff to make your game run on a typewriter (not necessarily written in order of importance):

- Never let the engine read code every step that isn't necessary to read every step.
- Use a state machine logic instead of tons of unorganised conditions.
- Use the less surfaces possible. Limit your draw calls the best you can.
- Mess with data structures only when absolutely necessary.
- Do not use precise collisions unless explicitly needed.
- "Tile" series of functions are generally pretty costly and so is the "move_" series of functions too. Try avoiding their use.
- Keep your larger files like backgrounds as small as possible. (for tilesets size doesn't really matter)
- Try to avoid included files and streamed audio.
- Deactivate whatever isn't visible on screen.
- Don't check for joystick or gamepad every step. Check every 5 steps or even less often.
- Make sure you have the "Short circuit evaluations" checked in the "General" tab in your global settings
- Maybe have an option for the player to disable the application surface if the game is running slow. You can even give them a "30fps mode" by disabling the draw event 1 step out of 2.
 
B

blutzauger

Guest
I see. Looks like 500 still too much, huh? I'll take note of that. I just don't notice, so far, any framerate drop in my game though, but I'll see what I can do. I finally found a problem though... The draw event refreshes visuals for every frames, right? Is it possible to only refresh once, for example once I clicked a button. It's been bugging me since I think drawing text every frame is still hogging memory. What do you think?
 

RangerX

Member
Depends on what your game is and what is its needs.
Every step, GameMaker is drawing your game on a surface (application surface) and then it resizes it, centers it and draw it for you. Whatever is in your draw events is actually drawn on that surface every step and then the surface itself it drawn on screen. I don't think you should start the mess around with drawing certain stuff at certain steps and whatnot. It can become extremely complicated for possibly poor results.
 
B

blutzauger

Guest
I see. I'll try not to mind too much about it then. Another question then, does having too much global variables actually cause slow down. Right now, I think I have more than 10,000 global variables crammed into one global controller object (which is persistent all throughout my rooms). I use it as various data for my items and such. Just like what I told earlier, so far it isn't causing too much trouble. Just in case, since I'm planning to add another set of items in the near future.
 

RangerX

Member
A variable containing data like numbers weights almost nothing. You can have TONS of them without any performance impact. This unless you read and update millions of them in the same step I can't vouch for it will perform well. ;)
 
B

blutzauger

Guest
I see. Thanks. I'll try to put updates to my game here once I'm more confident about it. It's named "Hulliry". It's a side-scrolling JRPG inspired by Odin Sphere.
 
M

mariospants

Guest
Can you be more specific as to what you meant by "sudden drop"? Was your framerate fine until you did some modifications/additions and now the whole game is slow or does the game slow down suddenly at a certain point? Because the answer to both questions, while related, may be completely different.

I think you've got a lot of great advice above and on this forum to answer the first question, but for the second, you'll have to do some sleuthing:

  • what changed since the last good build that didn't have the slowdown?
  • try removing or commenting out the last few things you did, one at a time, until you see improvement
  • you possibly have a memory leak: is your code causing some kind of repetition that's generating too many whatevers? Are you generating too many arrays or too many particles?
  • are you leaving too much in memory, such as persistent rooms, data structures, graphics that are too big or not being used, high-res audio?
Good luck paring it down!
 
B

blutzauger

Guest
Thanks for the reply. There wasn't really a sudden drop to my game thus far. The question really here is what pitfalls I should avoid in order to prevent those sudden drops in frame rate. So far, I'm still good. The only thing in my game so far are the global variables, a little bit of small pixel arts (walking animation for the player), menu GUI, start screen and a few tiles for the background. I'll take note of the points you mentioned if I did finally encountered those sudden drops. Thanks.
 
A

Aura

Guest
So you're basically asking for precautions that should be taken to prevent yourself from pitfalls, right?

Although there are too many of them to be listed in the same place, I'd like to link you to some resources. The first list that you should check out is this one -- a little bit outdated, but it still has some potential. Another useful resource is this one so be sure to check them out.
 
B

blutzauger

Guest
So you're basically asking for precautions that should be taken to prevent yourself from pitfalls, right?

Although there are too many of them to be listed in the same place, I'd like to link you to some resources. The first list that you should check out is this one -- a little bit outdated, but it still has some potential. Another useful resource is this one so be sure to check them out.
Thanks for the given links above. I'll make sure to give a read.
 
Top