Scene organization and game structure - how far do I go?

So I think I am pretty good at this, but I was just re-reading this:

But I break lots of these guidelines. So I was just wondering how seriously I should take them.

You see, I was just about to split my mission_manager into more fine grained nodes as it currently does mission generation, progress checking and some mission management. This was because my Dialogue Manager had to generate dialogue that relied on information tied up in the mission generator and the progress checker, and the game manager. It was all getting a bit messy you see and testing was getting difficult.

So I plan on grouping these current managers (all currently children of the main game node:

MotherShip
GameManager
MissionManager
TargetsManager
Camera
ChunkManager
EnvironmentManager
BaseManager
WeaponsManager
PlayerManager
UIManager
ExplosionsManager
HumansManager
EnemyManager
ItemManager
BuildingsManager
MachinesManager
PauseManager
DialogueManager

Into these groups:

GameCore
World
Entities
GameplaySystems
UI

And then saving some of the systems like DialogueManager and ChunkManager and many others as separate scenes for use in other games. I currently have real trouble sharing stuff between games and currently rely on cut and paste between scripts at the moment.

Anyway, that was why I was rereading the article above. I mean I do some of the things of course, like node initialisation routines, and use of signal managers, file managers, and settings files from globals routinely (player settings, game settings, mission settings etc.) but I have only just started using callables… (which I have loved btw).

So how far should I go with this?

So, why does all this complex switcheroo work? Well, because scenes operate best when they operate alone.

They are all certainly ‘close’ to being ‘loosely coupled’, but as I said, I do break the guidelines and probably sometimes more than I care to admit. Is it the case that a better developer would do these things naturally, and I should just shut up and put the work into correcting all these things because in the long run it is just better? Or do I just hang in there with what I am doing and get on with it and not worry about it.

I really don’t know. I think it would be a couple of weeks at most to do it (getting all the modules to be very loosely coupled or completely stand alone). Shall I just get on with it and try to produce the best most uncoupled code I can. Or is this only something to worry about long in the future should a game become a success of sorts?

Any input or advice or commentary would be warmly welcomed. Thank you in advance! (I need to practice being a bit more concise too I think).

Better is a very subjective judgement. You need to be asking yourself what works best for you right now.

As for your question, my answer is “yes”. You should be re-factoring your code on a regular basis, doing everything you can to make it “better” - but in order for that to happen you need to have code that needs re-factoring.

My personal approach is fairly simple. Get it working, clean it up. In the long run, clean and loosely coupled code saves a ton of effort, but I find that if I try to achieve that from the start I end up being less productive. I save the polish for when the code is working, though I do try to not let a large amount of technical debt build up.

Since you seem to have a large amount of code to polish, I would recommend not doing it all in one go. Do a bit each day, but work in some new development as you go. The goal is to have the task done 100% before release - you do not have to do everything right now.

Because who is to say your game won’t be a success? Far better to have a little bit of ego and assume the world will love your art, than to assume writing sloppy code won’t come back to bite you.

1 Like

I did it. Thanks for your advice @that_duck

And it did take 2 weeks as I guessed in the first place. However the current game loop is now working perfectly!

I am really pleased I did the work, although at times it was very frustrating. I could not do it in parts as it all needed to be done at once. But I am so glad I did because everything makes so much more sense now. I refactored so many scenes, including the pitt crew and the player, and the terrain generation and mission generator, and the dialogue manager, which are all now beautiful and so much more efficient. I managed to delete tons of unnecessary code as well and a few places where I went round in circles for no reason.

So two weeks of hard slog and my game looks almost exactly as it did before! Still worth it I think. Now back to the fun stuff!

At least for the future I will not be doing first drafts quite so quick and dirty as I did this time around. It just builds up too much of a mess to clean later. And some annoying bugs have disappeared too! All in all, I think it was a success. And I once again have a clean save point I can revert to if necessary on github.

And the advice in that original doc is actually pretty good advice I probably should have heeded earlier.

Worth it, but glad it’s over with (at least until next time)!

1 Like