Game Loop
How CNA's Game base class drives GalaxyEggbertCnaGame each frame.
Loop Ownership
GalaxyEggbertCnaGame does not implement its own loop — it inherits one from CNA's
Microsoft::Xna::Framework::Game base class (XNA-style: LoadContent
once, then Update/Draw every frame with a GameTime).
Update(GameTime& gameTime)
void GalaxyEggbertCnaGame::Update(GameTime& gameTime) {
Game::Update(gameTime);
worldRuntime_.Update(dt); // advances 6 fps tile-animation phase
auto keys = Keyboard::GetState();
float dx = /* from arrow keys */;
float dz = /* from arrow keys */;
bool jump = keys.IsKeyDown(Keys::Space);
blupi_.Step(worldRuntime_.GetWorld(), dx, dz, jump, dt);
camera_.SetTarget(blupi_.GetPosition());
camera_.Update(dt);
}
Draw(const GameTime& gameTime)
void GalaxyEggbertCnaGame::Draw(const GameTime& gameTime) {
device.Clear(Color(0.392f, 0.584f, 0.929f, 1.0f)); // sky blue
device.SetDepthTestEnabled(true);
terrainEffect_->View = camera_.GetViewMatrix();
terrainEffect_->Projection = camera_.GetProjectionMatrix();
terrainEffect_->World = Matrix::Identity;
terrainRenderer_->Draw(device, *terrainEffect_);
}
Tile Animation Timing
GEWorldRuntime::Update(dt) accumulates an internal timer and advances
animPhase_ at a fixed period of 1/6 second (6 fps) — matching both
GalaxyEggbertSimple3D and mobile-eggbert's original animation rate.
GETerrainRenderer checks GetAnimPhase() and only rebuilds its animated
cube mesh when the phase actually changes.
What's Missing Compared to a Full Game Loop
- No phase/state-machine dispatch (
GamePhaseexists as an enum but nothing switches on it in CNA yet). - No fixed-timestep accumulator — CNA's own
Gameloop timing model is used as-is. - No pause, no menu, no win/lose handling.