Technical Working 2: Electric Boogaloo


EDIT 5/24: Thanks to a user on my discord I found out that none of the previous devlogs had the images loading, so I've gone back and fixed this and the last one's to properly display images :)

Quickie: I'll be briefly going over what I did, if you join my discord @ https://discord.gg/q6grgzEahk you can talk directly to me to find out more.

The Parent-Child relationship:

A good rule of thumb for Node Communication is Call Down, Signal Up.


Referring back to this diagram I made in the last log, the Parent (Battle System) has Children (Player, Enemy, UI elements). If possible to manage, all the green arrows should be going downwards and not up. UI buttons shouldn't directly access Player, UI shouldn't access Enemy etc. I COULD pass Player/Enemy context to UI to negate this, but that wouldn't be good either, and it becomes harder to manage if anything else follows with this.

A Possible Solution: Singletons

For those of you reading who aren't exactly savvy in programming, a Singleton is a single static object, with the ability to allow anything to access it. The player, enemy, and UI buttons will now call functions from Battle Context to get access to other parts. Now my chart looks like this.

This creates a layer between all the objects, but doesn't quite solve the problem.

I've made another diagram to show a situation that can happen.


I've added new connections with a red line to show other things, when added, would have access to the singleton. This is bad, because Random Thing #2 at any time could make a call to Battle Context or change something. This will make finding bugs and glitches harder because I have to search through everything to figure out where it's happening. 

I'm working on a better solution and I'll upload another devlog when I'm done explaining it.

Leave a comment

Log in with itch.io to leave a comment.