Split the simulation from presentation into an SDL-free library

Sim holds one whole game (tick, snapshots, checksum) and talks to the screen only
through Cues, which the client's Scene plays and the server ignores. All drawing
moved to scene.cpp. Match takes this screen's wishes as request flags instead of
reading the menu, input and settings. The sim library builds without SDL and the
server links it, ready to run games itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-11-08 01:46:07 -05:00
1 parent 2007fb7edc
commit 465f75f6d7
38 files changed
+2225 -1965

No files matched your search

+20 -14
View File
@@ -1,11 +1,15 @@
#pragma once
#include "dmath.h"
#include <SDL3/SDL_filesystem.h>
#include <SDL3/SDL_stdinc.h>
#include <cmath>
#include <cstdint>
#include <string>
using Uint8 = std::uint8_t;
using Uint16 = std::uint16_t;
using Uint32 = std::uint32_t;
using Uint64 = std::uint64_t;
constexpr const char* GAME_ID = "smack-a-brother";
constexpr const char* GAME_NAME = "Smack a Brother";
constexpr int CANVAS_HEIGHT = 360;
@@ -124,18 +128,26 @@ inline float angle_lerp(float from, float to, float t)
return from + std::remainder(to - from, 2 * PI) * t;
}
// Cosmetic randomness: particles, flicker, shake. Gameplay draws from Rng instead.
inline float random_get(float min, float max)
{
return min + SDL_randf() * (max - min);
}
constexpr int RNG_FRACTION_BITS = 24;
constexpr int RNG_SHIFT_A = 13;
constexpr int RNG_SHIFT_B = 17;
constexpr int RNG_SHIFT_C = 5;
constexpr Uint32 RNG_SEED = 0x9E3779B9;
// Describes a spray of square particles, fanned around angle by spread. Fill is how far their colour takes over their
// black middle.
struct Burst
{
float angle = 0;
float fill = 0;
float gravity = 0;
float life = 0.4f;
float size = 3;
float speed = 100;
float spread = PI;
int count = 8;
};
// A small seeded xorshift generator for gameplay, saved with the simulation so a replay draws the same numbers.
struct Rng
{
@@ -209,9 +221,3 @@ template <class T, int N> struct FixedList
count = kept;
}
};
// Absolute path to a file inside the resources folder next to the executable.
inline std::string path_get(const char* relative)
{
return std::string(SDL_GetBasePath()) + "resources/" + relative;
}