GMS 2.3+ Please ELI5 why I'd use function constructors/methods over basic parent/child object inheritence?

ajrdesign

Member
I've been watching tutorials and reading about these things for about 3 hours now and I still cannot wrap my brain around it. I'm trying to figure out why I'd ever use these new features over the basic parent child relationships between objects that already exists? What scenarios do these new features really shine?

I've been thinking about how I could apply it to this type of structure:

o_ship (parent):
  • Hit/Armor/Death functions
  • Status effects that can apply to all ships
  • Movement AI options for all types of ships
o_enemy_ship (child of o_ship):
  • Drop rewards on death
o_specific_enemy_ship (child of o_ship, multiple varients of this type)
  • Various attack functions based on the ship

I've been racking my brain to figure out if there's any value in turning this structure into a more class like structure or if I should just stick with that's working right now.
 
I've been watching tutorials and reading about these things for about 3 hours now and I still cannot wrap my brain around it. I'm trying to figure out why I'd ever use these new features over the basic parent child relationships between objects that already exists? What scenarios do these new features really shine?

I've been thinking about how I could apply it to this type of structure:

o_ship (parent):
  • Hit/Armor/Death functions
  • Status effects that can apply to all ships
  • Movement AI options for all types of ships
o_enemy_ship (child of o_ship):
  • Drop rewards on death
o_specific_enemy_ship (child of o_ship, multiple varients of this type)
  • Various attack functions based on the ship

I've been racking my brain to figure out if there's any value in turning this structure into a more class like structure or if I should just stick with that's working right now.
The two aren't really equivalent. Parent-child object inheritance is still extremely useful for situations like you outlined. However, objects have a ton of bloat that isn't necessary for all purposes. All those built-in variables like x, y, speed, hspeed, vspeed, image_index, gravity, etc. take up resources that aren't necessary if you're just doing, say, a delta_time alarm system or an input framework. Overall, it's easier to think of structs as a vastly more powerful implementation of ds_maps. They can't do anything on their own, unlike objects. They're just a very convenient way of organizing and managing data and systems.
 
Top