group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
Game Class Reference

Top-level client game object. More...

#include <Game.hpp>

Public Member Functions

bool init ()
 Initialise all subsystems and spawn the local player entity.
 
SDL_AppResult event (SDL_Event *event)
 Forward an SDL event to ImGui and handle application-level keys.
 
SDL_AppResult iterate ()
 Advance one frame: sample input, step physics, render.
 
void quit ()
 Shut down all subsystems in reverse-init order.
 
void refreshRemotePlayerRenderables ()
 

Detailed Description

Top-level client game object.

Owns all subsystems: window, ECS registry, renderer, debug UI, and network client. Wired into SDL's application-callback API (SDL_AppInit / SDL_AppEvent / SDL_AppIterate / SDL_AppQuit).

Member Function Documentation

◆ event()

SDL_AppResult Game::event ( SDL_Event *  event)

Forward an SDL event to ImGui and handle application-level keys.

Parameters
eventThe SDL event to process.
Returns
SDL_APP_SUCCESS to quit, SDL_APP_CONTINUE to keep running.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init()

bool Game::init ( )

Initialise all subsystems and spawn the local player entity.

Returns
False on any fatal initialisation error.
Here is the call graph for this function:

◆ iterate()

SDL_AppResult Game::iterate ( )

Advance one frame: sample input, step physics, render.

Advance one frame: decoupled physics / render loop.

Returns
SDL_APP_CONTINUE normally; SDL_APP_SUCCESS on quit request.

Physics ALWAYS runs at exactly 128 Hz (k_physicsHz) using an accumulator with a multi-tick catch-up loop (up to k_maxTicksPerFrame per call). This is non-negotiable: it must match the server tick rate.

Input is split into two independent streams:

Mouse look (yaw / pitch) – sampled EVERY iterate() call so camera rotation is perfectly smooth at whatever frame rate the renderer produces. The camera always uses the latest yaw directly (never interpolated). Interpolating yaw with the physics alpha creates a timebase mismatch on multi-tick or zero-tick frames, producing visible jitter.

Movement keys (WASD / jump / crouch) – sampled once per physics tick group when inputSyncedWithPhysics is true (the default) so movement calculations match the server. When the toggle is off, keys are also sampled every iterate() call.

Position interpolation uses alpha = accumulator / k_physicsDt across the LAST physics tick (PreviousPosition is saved inside the while loop before each tick).

Three ImGui-tunable flags:

renderSeparateFromPhysics – render every iterate() call with position interpolated between the last two physics ticks (true, default) vs. render only after a physics tick (false, caps render fps at 128 Hz).

inputSyncedWithPhysics – sample movement keys once per tick group (true, default, server-consistent) vs. every iterate() call (false). Mouse look is always per-frame regardless of this toggle.

limitFPSToMonitor – VSync on (true) / off (false, default).

Here is the call graph for this function:

◆ quit()

void Game::quit ( )

Shut down all subsystems in reverse-init order.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ refreshRemotePlayerRenderables()

void Game::refreshRemotePlayerRenderables ( )
Here is the caller graph for this function:

The documentation for this class was generated from the following files: