D
DarklinkFighter
Guest
Hi,
as a C++ / C# / Java Programmer I struggle a bit now when I want to refactor some stuff from my first Test Project with GMS2...
I tend to break my head when it's better to use composition and when it's better to use parenting in Game Maker...
In other languages I can just implement multiple interfaces for different Game Objects but with Game Maker I am scared to decide what code to put where now...
Because if I use parenting very heavily but all of the sudden need some different logic for some childs... I can only turn of the complete inherited logic or run it... And with that there could be multiple overrrides of variables which are maybe already handled with instance_creations in parents... or some order issues...
My current problem...
For example I think of just making player, destructable and enemy a child of a new object like obj_game_object but I am scared if some childs need other behaviour later that I break everything for them because event_inherited is not called anymore :/
Do you guys have some examples, what good fits are for parenting and what are not?
as a C++ / C# / Java Programmer I struggle a bit now when I want to refactor some stuff from my first Test Project with GMS2...
I tend to break my head when it's better to use composition and when it's better to use parenting in Game Maker...
In other languages I can just implement multiple interfaces for different Game Objects but with Game Maker I am scared to decide what code to put where now...
Because if I use parenting very heavily but all of the sudden need some different logic for some childs... I can only turn of the complete inherited logic or run it... And with that there could be multiple overrrides of variables which are maybe already handled with instance_creations in parents... or some order issues...
My current problem...
- OBJECTS
- obj_player -- Uses hurtable_entity & movement_entity component, has lifepoints, has own loot drop logic, uses own state machine
- obj_enemy -- hurtable_entity & movement_entity, has lifepoint, has own loot drop logic
- obj_bat -- uses own state machine
- obj_skeleton -- uses own state machine
- obj_destroyable -- Uses hurtable_entity component, has no lifepoints, blocks movements, has a own multi loot drop logic
- obj_grass -- does not block movements
- obj_bush
- obj_tree -- But this one turns off the destroyable...
- obj_hitbox -- all objects which use hurtable_entity use this with a collision event
- obj_projectile -- movement_entity
- obj_arrow
- obj_projectile -- movement_entity
- COMPONENT SCRIPTS (initialises or use Variables and control behaviour relative to that)
- movement_entity -- speed, direction, friction, bounces
- hurtable_entity -- for example isInvincible, invincible_time, canHitBy
For example I think of just making player, destructable and enemy a child of a new object like obj_game_object but I am scared if some childs need other behaviour later that I break everything for them because event_inherited is not called anymore :/
Do you guys have some examples, what good fits are for parenting and what are not?