Week 7: Game Loop
Finally, Running Late knows if you're running late.

It sounds like a small feature, and it is, but the game finally has win and loss conditions. Up until now, you could run around the cockpit, fix oxygen filters, restore power, and navigate through space, but it was just a collection of interconnected systems without stakes. Now, the game tracks your distance to the wedding and monitors how much time has passed. If you run out of air, it knows. If you take too long, it knows. And if you make it to the station, it knows that too.
Bound up with that was a week of the kind of work that doesn't screenshot well. Moving variables around, restructuring object relationships, building restart functionality that actually works, encapsulating game logic into appropriate systems. Boring but useful work that clears the way for everything else.
Everything In Its Place
I'd been storing all the game data in the Game Instance—an object Unreal uses to keep track of variables from level to level. From the amount of oxygen remaining to the ship's orientation, I kept it all in this global variable space. Early on, this meant quick development and easy wins.
But I realized that when you do finally win or lose the game, you may want to play again. That was a little bit of a problem. When the game is over, hitting "Restart Game" should reset everything to the beginning, but that meant manually resetting dozens of variables.
Of course, there's a clean way to do this. I migrated everything to the Game State object—an object Unreal creates at the beginning of the level. A clean restart now just means reloading the level. Moving all that data took some time. I had to update all the game instance references, test every system, and make sure nothing broke in the transition. It was work perfect for an evening or two of lofi and Diet Coke. And I found a few places I could simplify the code while I did it, too.

The Conditions that Matter
With cleaner state management, implementing win and lose conditions became easy. The game now checks three things every frame.
- If your oxygen hits zero, you pass out. (Not die—this is a comedy about wedding panic, not survival horror.)
- If an hour passes, you're officially too late for it to matter. (This may change, depending on how much content I can create.)
- If your distance to the station reaches zero, you've made it. Huzzah!
Each condition triggers its own game over screen with appropriate messaging. "You passed out from lack of oxygen!" hits differently than "You missed the entire wedding!"
Now, it's super easy to restart the game. Bring up the pause menu after you lose and then just hit the restart button. Voilà, a fresh Game State with starting values is loaded up cleanly.
The Quiet Moment
There's a specific feeling when some connected mechanics become an actual game. It's not dramatic—as much as I'd love an audio cue with glowing outline. It's more like making a sandwhich. You can put bread and cheese on a plate, but when you stack them just so, it becomes a sandwhich.
I loaded up Running Late, pulled the air filters, watched the oxygen drop, hit the game over screen, clicked restart, and everything reset. Beginning to end, the core loop worked. You can play it, lose it, try again.
Of course, it's still very rough around the edges. The game over screens are placeholder-level basic. The win condition is just "distance equals zero" without any ceremony. But what it is now, is a game.
Next Up
Now I need to make it a fun game. Environmental hazards are next on the list. Everything from asteroid impacts to electrical storms to put pressure on the player. This will create the slowly escalating chaos of a barely spaceworthy clunker trying to get you to the other side of the solar system before the reception.