GML Is it better for run-time to have multiple objects or a single object with multiple states?

XirmiX

Member
Lets say you want to have different types of projectiles for different weapons. Would it be wiser for better fps to have an object for each projectile type or have the projectile be a single object that has different types?
 

Binsk

Member
GameMaker has objects for this reason, use them.

Everything is executed sequentially, no matter how you make it. There isn't multi-threading.

Objects require a tad extra overhead in both memory and CPU but it is minimal in the big scheme of things and, honestly, with the number of variables and checks you would need to fit everything in one object it would probably just turn out faster (let alone easier) to just use multiple objects.
 

Smiechu

Member
It's really very dependant from the situation...

In situation when you have many similar but a little bit modified "things" (like projectiles) in your game you should take advantage of separate objects and parenting...
The similarities in code should be placed in parent and differences in children objects...

But when you have some sort of complicated gameplay functionality like A.I., economic systems, level creation etc... or things that change states very dynammically... they should be in scope of onw object.
 
Top