Profile stats, first-run hints, tiered balance, a wave-driven whip, and more options
- Profile Stats: damage dealt, kills and wins (single player and multiplayer) and the most and least played weapons and trinkets, counted from running totals in the simulation so online rewinds correct them. Protocol 6. - First-run control hints in the sandbox (and Chat in lobbies), each gone for good once used. - The ready countdown and a timed round's last five seconds beep (new countdown sound), and those seconds show big. When time runs out, everyone short of the most health dies. - Weapon balance tuned into tiers: Whip and Grenade Launcher on top, then melee, ranged, and utility (Vacuum, Grapple, Uzi) at the bottom. - The whip's lash is a chain of links a wave rolls down: windup, loop, crack, then a floppy recoil. - Muzzles come from Muzzle nulls in weapons.anm2 (read in at build time), for shots and the flash, which now follows the weapon. - Settings: Quit, Scale (1x-4x or Free), FPS meter and limit beside Vsync, Mute on Unfocus, Damage Numbers, Rumble, Stick Deadzone, and an Online section (Host, Chat, Ping) shared with the Multiplayer page. - The menu header lays out tabs and buttons by their names. About is sandbox-only. The score no longer shifts with the menu's tab. - Smaller meters, 90 tips (all ending in !), and a shorter lobby welcome.
This commit is contained in:
1 parent
e9d8cac926
commit
b96defa1e6
32 files changed
+1368
-396
No files matched your search
+36
-1
@@ -6,6 +6,8 @@
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <algorithm>
|
||||
|
||||
// How early a browser frame may come and still go under the frame rate limit.
|
||||
constexpr Uint64 FRAME_SLACK = 2 * SDL_NS_PER_MS;
|
||||
constexpr int WINDOW_SCALE = 2;
|
||||
constexpr double MAX_FRAME_TIME = 0.25;
|
||||
#ifdef SDL_PLATFORM_EMSCRIPTEN
|
||||
@@ -69,6 +71,7 @@ void game_tick(Game& game)
|
||||
static void presentation_update(Game& game)
|
||||
{
|
||||
game.effects.update();
|
||||
game.stats.update(game);
|
||||
game.ui.update(game);
|
||||
game.scene.update();
|
||||
game.cameraPrevious = game.camera;
|
||||
@@ -122,6 +125,8 @@ struct FrameClock
|
||||
|
||||
static Game game;
|
||||
static FrameClock frameClock;
|
||||
// When the next frame is due under the frame rate limit (see frame_wait_get), in nanoseconds.
|
||||
static Uint64 frameDue = 0;
|
||||
|
||||
// One frame's input and as many fixed ticks as the time since the last frame allows.
|
||||
static void frame_step()
|
||||
@@ -169,6 +174,28 @@ static void frame_step()
|
||||
game.alpha = frameClock.accumulator / TICK;
|
||||
}
|
||||
|
||||
// The frame rate limit in use: none while vsync paces the frames.
|
||||
static int frame_limit_get()
|
||||
{
|
||||
return game.settings.isVsync ? 0 : game.settings.fpsLimit;
|
||||
}
|
||||
|
||||
// How long until the frame rate limit lets the next frame go, in nanoseconds.
|
||||
static Uint64 frame_wait_get()
|
||||
{
|
||||
Uint64 now = SDL_GetTicksNS();
|
||||
return frame_limit_get() > 0 && frameDue > now ? frameDue - now : 0;
|
||||
}
|
||||
|
||||
// Sets when the frame after this one is due under the limit: a limit's worth of time after this one was due, or after
|
||||
// now if it ran late, so a slow frame doesn't bring on a burst to catch up.
|
||||
static void frame_due_advance()
|
||||
{
|
||||
int limit = frame_limit_get();
|
||||
if (limit > 0)
|
||||
frameDue = std::max(frameDue, SDL_GetTicksNS()) + SDL_NS_PER_SECOND / limit;
|
||||
}
|
||||
|
||||
// One frame, stepped and drawn. Returns whether to keep going.
|
||||
static bool frame_run()
|
||||
{
|
||||
@@ -178,8 +205,13 @@ static bool frame_run()
|
||||
}
|
||||
|
||||
#ifdef SDL_PLATFORM_EMSCRIPTEN
|
||||
// The browser paces the frames itself, so under a frame rate limit those that come too soon are skipped (one that's
|
||||
// only FRAME_SLACK early still goes, for screens refreshing a shade fast).
|
||||
static void frame_callback()
|
||||
{
|
||||
if (frame_wait_get() > FRAME_SLACK)
|
||||
return;
|
||||
frame_due_advance();
|
||||
frame_run();
|
||||
}
|
||||
|
||||
@@ -276,9 +308,12 @@ int main(int argc, char** argv)
|
||||
});
|
||||
return 0;
|
||||
#endif
|
||||
while (frame_run())
|
||||
do
|
||||
{
|
||||
SDL_DelayPrecise(frame_wait_get());
|
||||
frame_due_advance();
|
||||
}
|
||||
while (frame_run());
|
||||
|
||||
game.settings.save(game);
|
||||
game.net.shutdown();
|
||||
|
||||
Reference in new issue
Block a user