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

Many objects vs. large objects?

W

Wigfrid

Guest
Hello

I have 2 situations.


1 object with a sprite of 6400*6400

or

100 objects with a sprite of 64*64

All object instances are placed exactly the same, to form a rectangle.


Which situation is better in terms of efficiency, and how much more efficient is one compared to the other?

probably the answer is obv the first one, but just how much more effificent? I have a game already big enough that I accidentally coded with the second situation... My game is running a bit slow and I think this is the cause, how much will I gain in terms of performance if I were to revamp my game?

Thanks so much.
 

YoSniper

Member
If the 6400x6400 sprite is not terribly complicated, and does not contain a lot of transparent parts (or more importantly, does not have a complicated hitbox,) then the single object with a large sprite might be the better bet.

If the 100 objects form a complicated shape and/or hitbox, then I would go with the 100 smaller objects.

I would also use more of the smaller object if the code is easier to recycle and you can just place the same kinds of objects in various forms throughout the game.
 

Slyddar

Member
With 100 smaller objects, gamemaker needs to process each object every step. They all have their built in variables, and depending on their code, they will all need to run it each step too. Compare this to a single object running once per step, and the once per step will be much more efficient. Even objects that have no code will have a performance overhead, as they are still being managed by GMS.
 
W

Wigfrid

Guest
Okay, I get it now, I might consider revamping my game then, thank you so much everyone!
 
However, a sprite that is 6400x6400 will be larger than most computers can handle and your texture page will automatically resize it downwards unless you change the size your texture pages can be. When the sprite gets resized for the texture page it will lose clarity. So be aware that you don't want to be using sprites that large. If you need a sprite that large, cut it into smaller chunks and have the single object draw each chunk in the correct position.
 
Top