Initial commit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-11-08 01:30:33 -05:00
commit 2007fb7edc
200 files changed
+27710

No files matched your search

+103
View File
@@ -0,0 +1,103 @@
#pragma once
#include "audio.h"
#include "balance.h"
#include "bot.h"
#include "chat.h"
#include "menu.h"
#include "effects.h"
#include "fighter.h"
#include "input.h"
#include "match.h"
#include "net.h"
#include "renderer.h"
#include "rollback.h"
#include "session.h"
#include "settings.h"
#include "sprites.h"
#include "text.h"
#include "trinket.h"
#include "ui.h"
#include "weapon.h"
#include "world.h"
constexpr float PVP_OFF_SHADE = 0.4f;
constexpr float AWAY_SHADE = 0.2f;
// Every manager in one place, so systems can reach each other through a single reference.
// Devices say which input plays each fighter on this screen (none for bots). Fighters, the match and rng belong to the
// simulation and are saved in snapshots. Local is the fighter this screen
// controls and follows. Camera, alpha, settings and the window are presentation. Alpha is how far drawing sits between
// the previous tick and the current one. Net is the connection to the server and other players.
struct Game
{
Audio audio;
Balance balance;
Bot bot;
Chat chat;
Menu menu;
Effects effects;
Fighter fighters[MAX_FIGHTERS];
Input input;
Match match;
Net net;
Renderer renderer;
Rollback rollback;
Settings settings;
Session session;
Sprites sprites;
Text text;
Ui ui;
Weapons weapons;
World world;
Rng rng;
Vec2 camera;
Vec2 cameraPrevious;
float alpha = 1;
int devices[MAX_FIGHTERS] = {DEVICE_KEYBOARD, DEVICE_NONE, DEVICE_NONE, DEVICE_NONE};
int fighterCount = 1;
int local = 0;
SDL_Window* window = nullptr;
Fighter& local_get()
{
return fighters[local];
}
// Whether a fighter is played on this screen, by its keyboard and mouse or one of its gamepads.
bool is_local(int fighter)
{
return fighter < fighterCount && devices[fighter] != DEVICE_NONE && !fighters[fighter].isBot;
}
int local_count()
{
int count = 0;
for (int i = 0; i < fighterCount; i++)
count += is_local(i);
return count;
}
// A fighter's colour: its match colour (handed out when the match starts), or in the sandbox this screen's own
// (picked in Customize, white while unassigned) until others join, when everyone
// gets one. With others in the sandbox, everything of another fighter is darkened on this screen unless it and this
// screen's own both have PvP on (so they can hurt each other); this screen's own always shows in full. Asked for
// plain (as the HUD's tint is), it's never darkened.
Color color_get(int fighter, bool isPlain = false)
{
if (match.state == MATCH_PRACTICE && fighterCount == 1)
{
int color = settings.color_get();
return color >= 0 ? PALETTE[color] : WHITE;
}
Color color = PALETTE[match.colors[fighter]];
// Away playing a queued game, a fighter stands faded in the lobby.
if (match.state == MATCH_PRACTICE && match.isAway[fighter] && !isPlain)
return color_shade(color, AWAY_SHADE);
bool isHostile = fighters[fighter].isPvp && fighters[local].isPvp;
bool isPeaceful = !isPlain && fighter != local && match.state == MATCH_PRACTICE && !isHostile;
return isPeaceful ? color_shade(color, PVP_OFF_SHADE) : color;
}
};
void game_tick(Game& game);