A survival game needs to start at a menu, let the player avoid enemies, and show a game-over screen. If every GameObject runs its own initialization and frame updates, it becomes harder to tell which code runs when. A single Game script can instead drive the main loop: it owns the flow between menus and gameplay and calls other components in a deliberate order. section 5.1.1
Game holds the Balance rules, mutable GameData, and menu references. Its Unity Start() allocates and initializes long-lived game data, initializes Board, and activates the main menu. Its Update() calls Board.Tick() each frame when gameplay needs to run. Board collects player input and displays the action; Logic modifies GameData. Game coordinates these parts rather than putting every responsibility into one script. section 5.3.1 section 5.4 section 5.5
Keep control of execution and state in one place:
- Have Game call Board.Init() instead of relying on Board.Awake() or Board.Start(). This makes initialization and allocation order explicit. section 5.1.2
- Have Game call Board.Tick() instead of giving Board its own Update(). A breakpoint in Game then provides a starting point for tracing each frame. section 5.1.1 section 5.1.2
- Route menu changes through Game: update MenuState through Logic, hide the previous menu, and show the next one. section 5.1.1
Listing 5.12 We use Unity’s Start() to initialize our data
void Start()
{
Logic.AllocateGameData(m_gameData, m_balance);
Board.Init(m_balance);
UIMainMenu.SetActive(true);
UIGameOver.SetActive(false);
}The Start() listing shows the entry point doing three concrete jobs: allocating GameData, initializing Board, and setting the initial menu visibility. section 5.3.1
The loop can keep driving the same objects as levels or menus change. Store the current state in GameData, load different level values from Balance, and show or hide menu GameObjects rather than making each level or menu a separate scene. One scene is a simplicity choice here, not a requirement that every Unity project abandon its scene workflow. section 5.1.4
