Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | skonar2 |
Hi!
I’m not a very advanced coder, so, keep that in mind. But I do like planning what I’m going to do ahead of time, so…
I’m planning a very simple 4x game, and I think there’s going to be a lot of global data to pass between scenes and screens. Currently I have two screens - space screen, to show planets and stars and where the units are on those planets and stars, and battle screen, to do battles.
I COULD implement all of this in a single scene with dialogue menus or something, but I’m trying to code this in such a way it helps me understand what I’ll need to do for more complex versions. Right now the battle screen is just a fancy dice rolling spread sheet, but, one day maybe it’ll be a turn based hex grid thing, so, it’s a separate scene.
My units are really simple at this stage, with just one kind of unit - a battlepod - but I want to implement them as individual objects so later I can do things like give each unit a history, unique loadouts, xp points, all that.
So, firstly:
I’m not sure if I should be implementing my battlepod units as a node that spawns on the space screen, then when I switch to the battle screen I somehow save the space screen data (where the planets are, what units are on them), pass the units that are in battle to the battle screen, do the battle, then re-load the space screen data, repopulate the space screen, and modify the space screen with the battle results…
OR, if I should be implementing my battlepod units and space screen data as some kind of global object - like the autoloads - which persist no matter what scene I have loaded, and then in each scene have some kind of code to create new nodes to show the relevant sprites in the right places.
The other big issue is I’m not sure how to handle displaying the units on the space screen. My plan is to have an icon appearing next to each planet, representing a unit, with a number beside it to show how many units are on the planet, but I’m not sure how best to count them. I was thinking about some kind of function to make the battlepod units ‘report’ their location to the planet, and then have the planet count the number of reports? Would that work, or is there something more elegant I could do?
Can anyone offer opinions on all this? Advice? Or maybe tell me if there’s a better approach I’m missing?