• 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!

GML I figured out how to have huge room sizes and no FPS drop.

L

lord_berto

Guest
Titled says it. of coarse u can check if an object is in view,
and you can even loop through all Ur objects or tiles. But things become problematic when you start increasing
your room size. it'll be loooots of checking if ur room is 10,000x10,000.

well i figured out how to check for only the important area (the player's surrounding area) and now rooms are not only fast in 10,000 , or 20,000 or 40,000 pixels big. I made a room that is of 180,000 pixels big, filled it with textures and tree objects and runs on average 1700fps, with a high of 5000~fps Just as if my room was to be only 1024x768 pixels big.

Its a cool system i made and you decorate your level just like you would, meaning u place everything (except the background, which you should draw yourself) and tada!
this would mostly be useful for open world games.

here are some tips if you consider coding this yourself.
-Never use the default background settings, draw the background in repeating tiles using a for loop, but only in the player's surround area,
-dont use a constant for-loop to check if an object or tile is in view in the step event, check it only ONCE every few screen_widths that your player progresses
- Disable background color in the room settings

And for those of you wondering I tested this on a top down shooter that i am working on for mobile.
good luck!
 
N

NeoIdea

Guest
Awesome, I just figured out how to make an infinite room myself, so this information is appreciated.
 

Bingdom

Googledom
Alternatively, you don't even need to adjust the original room size. You can make the character leave the room boundaries which basically gives infinite terrain.

This requires a manual camera and depending on what you want, a some sort of chunk based system.
 
B

barshems

Guest
ya I wish someone had told me this when I was first starting could've saved me a lot of trial and error lol
 

GMWolf

aka fel666
Room size can be useful if you want to limit the camera movement and stop object from going too far.

Its also more relevant in GMS2 as I can imagine people will use the room editor a lot more now.
 

Yal

🐧 *penguin noises*
GMC Elder
Instance deactivation has more or less the same benefits, and it also stops enemies from moving until they get close enough to be active. I use that a lot~
 

GMWolf

aka fel666
Instance deactivation has more or less the same benefits, and it also stops enemies from moving until they get close enough to be active. I use that a lot~
yes, but you must be carefull: do not activate-deactivate every step! this will be very slow!
Instead, activate whenever the view moves a certain ammount.

A good alternative is to de-activate when the objects gets too far from the view border, and place it in a list. When the view moves, go through that list to reactivate when its back in a god range. This can be very well optimized with better data structures like trees.
 
T

tafkatfos

Guest
yes, but you must be carefull: do not activate-deactivate every step! this will be very slow!
Instead, activate whenever the view moves a certain ammount.

A good alternative is to de-activate when the objects gets too far from the view border, and place it in a list. When the view moves, go through that list to reactivate when its back in a god range. This can be very well optimized with better data structures like trees.
Or you can use an alarm instead of step event to activate/deactivate.
 
B

barshems

Guest
my problem is when the room_size is too big and it loads multiple new objects at once.. i'll lose about 3fps every time this happens and the screen sort of skips a bit.

does anyone know of a way to add a buffer to reduce loading lag?
 

GMWolf

aka fel666
my problem is when the room_size is too big and it loads multiple new objects at once.. i'll lose about 3fps every time this happens and the screen sort of skips a bit.

does anyone know of a way to add a buffer to reduce loading lag?
A good alternative is to de-activate when the objects gets too far from the view border, and place it in a list. When the view moves, go through that list to reactivate when its back in a god range. This can be very well optimized with better data structures like trees.
 
B

barshems

Guest
my problem is during the loading though not during actual run.

I have it setup already to unload objects that are out of range but when it's loading objects like 10-15 at a time I need some way to pause and resume or something to chop up the load
 

GMWolf

aka fel666
my problem is during the loading though not during actual run.

I have it setup already to unload objects that are out of range but when it's loading objects like 10-15 at a time I need some way to pause and resume or something to chop up the load
In that case, does it really matter? Have a loading splash screen or something. Many gomes do that!
alternatively, come up with your own room file format that you can load over multiple steps.
 
L

lord_berto

Guest
Room size is more or less irrelevant. My room is 8 x 8 pixels, yet my game is running at 2560 x 1080 Ultra-wide high def.

It's not about the room size, it's how you use it ;)

(Or was that something else? :p)
room size is actually pretty relevant. Try drawing a looping background for a 120,000x 120,000 world/level. Your going to be doing alot of FOR loops the bigger the size map = SLOW, with my code, room size doesn't affect my games performance.

Instance deactivation has more or less the same benefits, and it also stops enemies from moving until they get close enough to be active. I use that a lot~
even if you have an alarm, every 60 steps or which ever number you choose, YOULL still have to check for those objects/tiles, and the more objecs/tiles you have, the more it'll affect performance. With my code i only do a for-loop check, 1 time, every few screen widths with instances/tiles that were last active/visible.

Alternatively, you don't even need to adjust the original room size. You can make the character leave the room boundaries which basically gives infinite terrain.

This requires a manual camera and depending on what you want, a some sort of chunk based system.
yes, but this doesn't solve the issue of checking for objects, which is one of the biggest things that cause games to limit their room size/ instance amount. In a room that is 180,000 If you have non-static trees, or other Ai you definitely dont want to have all objects that are 10,000 pixels away active.



MOD EDIT: Please do not post multiple times in a row and either use the multi-quote forum tool (if replying to multiple people), or simply edit the previous post to add further information.
 
Last edited by a moderator:
L

lord_berto

Guest
So, nothing new to see in this thread then. :p
hey, maybe not for you.. but Im posting to let people know there is a way to have big rooms without affecting the performance.
Most people are limited because they use the default resource. props to you for knowing how to code this!
 
G

gamedev513

Guest
Titled says it. of coarse u can check if an object is in view,
and you can even loop through all Ur objects or tiles. But things become problematic when you start increasing
your room size. it'll be loooots of checking if ur room is 10,000x10,000.

well i figured out how to check for only the important area (the player's surrounding area) and now rooms are not only fast in 10,000 , or 20,000 or 40,000 pixels big. I made a room that is of 180,000 pixels big, filled it with textures and tree objects and runs on average 1700fps, with a high of 5000~fps Just as if my room was to be only 1024x768 pixels big.

Its a cool system i made and you decorate your level just like you would, meaning u place everything (except the background, which you should draw yourself) and tada!
this would mostly be useful for open world games.

here are some tips if you consider coding this yourself.
-Never use the default background settings, draw the background in repeating tiles using a for loop, but only in the player's surround area,
-dont use a constant for-loop to check if an object or tile is in view in the step event, check it only ONCE every few screen_widths that your player progresses
- Disable background color in the room settings

And for those of you wondering I tested this on a top down shooter that i am working on for mobile.
good luck!
Do you have an open-source example of this?
 

RangerX

Member
So what's the use of this thread if you don't put your code in here Lord Berto?
Or is it just to make a thread about you being good or being able to solve a problem? There's "Live Journal" for that you know.
 

Yal

🐧 *penguin noises*
GMC Elder
Well, he's pointing out the general theory...

Some questions though:
  • Are you using instance deactivation and is that affecting framerate?
  • Are any of your instances actually running code?
  • How do you handle stuff that needs to be always-active or happen outside the active region?
 

YanBG

Member
Example would be helpful, because i didn't learn anything new from this discussion. Maybe it works with repeating the same tile and not a "real" terrain?

For open world having detailed environment made out of different tiles, i have to first generate it or import a color coded map, then save/load tile values each time the player moves. There will be a lot of checks and i assume a huge load in memory for the 180k room data.
 
M

martin_soldat

Guest
Its easy

instance_deactivate_region(view_xview[0], view_yview[0], view_wview[0], view_hview[0], false, true);
instance_activate_region(view_xview[0], view_yview[0], view_wview[0], view_hview[0], true);
 

nb109

Member
What a crappy thread to necro...
And your contribution means nothing basically
Showed up high in Google searches for handling large rooms in Gamemaker, and he gave a practical starting point for code that could help people new to Gamemaker.
 

dialgpalkia

Member
Just discovered this post, but I am really struggling to follow exactly what you are suggesting I need to do to achieve this.
Do you have an example code or a step-by-step psuedocode explanation that I could work from?
 
Top