|
group2 0.1.0
CSE 125 Group 2
|
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 () |
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).
| SDL_AppResult Game::event | ( | SDL_Event * | event | ) |
Forward an SDL event to ImGui and handle application-level keys.
| event | The SDL event to process. |
| bool Game::init | ( | ) |
Initialise all subsystems and spawn the local player entity.
| SDL_AppResult Game::iterate | ( | ) |
Advance one frame: sample input, step physics, render.
Advance one frame: decoupled physics / render loop.
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).
| void Game::quit | ( | ) |
Shut down all subsystems in reverse-init order.
| void Game::refreshRemotePlayerRenderables | ( | ) |