Files
isaac-port/src/backdrop.h
T
shweetandClaude Opus 5.5 48933cd312 Curation round 9: floors and walls, room transitions, collision, the first enemies, saving, damage, pickups
Seven agents took over the backdrop's floor and wall rendering, room transitions (StartRoomTransition, on_leave,
room_enter), grid collision with tear hits and decal baking, Entity_NPC's core with the AI dispatch and the first
enemies (flies, Gaper, Pooter, Clotty, Horf, Dip, Spider), the run's save, player damage, PlayerManager::Update,
ShowName, pickups, slots and the common effects. Integration added LuaEngine::PostNewLevel/PostNewRoom, one shared
lua_callback_check (4 copies merged) and the enemy type range the original checks.
Under gdb a run draws its rooms with floors and walls, walks between rooms, fights Gapers with contact damage and the
damage flash, and collects pickups. Next: tears hitting enemies, pathfinding, item pedestals, death.
2891 functions taken over.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 08:24:38 -05:00

142 lines
4.4 KiB
C++

#pragma once
#include "anm2.h"
#include "kage_graphics.h"
#include <array>
#include <cstdint>
#include <string>
#include <string_view>
#include <vector>
// backdrops.xml fills ids 1 to 62. Id 0 is the default the others start from.
constexpr int BACKDROP_COUNT = 63;
// How a piece of a backdrop sheet is mirrored as it is drawn, by bit.
enum Flip
{
FLIP_NONE,
FLIP_X,
FLIP_Y,
FLIP_XY
};
// Which walls a wall detail sprite shows its layers on, by bit: the layers named h... on the top and bottom walls, the
// layers named v... on the side walls.
enum WallSides
{
WALL_SIDES_NONE,
WALL_SIDES_HORIZONTAL,
WALL_SIDES_VERTICAL,
WALL_SIDES_ALL
};
// Construction, copies, assignment and destruction (00931de0, 00934600, 00934430, 009324f0) are the defaults.
// A room background of backdrops.xml: its wall and floor sheet and how many walls and floors it cuts into, the floor
// overlays, the water, and the grid graphics (rocks, pits, doors ...) rooms of it use. Paths are under resources/.
struct BackdropConfig
{
std::string bridge;
std::string door;
std::string gfx;
std::string holeInWall;
std::string lFloorGfx;
std::string nFloorGfx;
std::string pit;
std::string props;
std::string rocks;
std::string spikes;
std::string waterGfx;
std::string waterPit;
int backdropId = 0;
int floors = 0;
int floorVariants = 0;
int walls = 0;
int wallVariants = 0;
uint8_t waterPitsMode = 0;
bool isFullImage = false;
bool isReverseWaterGfx = false;
};
// A cell of wall drawn into the wall surface, for the effects its backdrop adds there: where it was drawn, its place on
// the sheet's block (slotX along the top wall, slotY down the side wall), the sheet's wall row and its variant.
struct WallSlot
{
DestinationQuad quad{};
int slotX = 0;
int slotY = 0;
int variant = 0;
int wallRow = 0;
Flip flip = FLIP_NONE;
};
// A corner of the room's walls a wall detail sprite is drawn at, and how likely each of its layers shows.
struct WallDetail
{
Vector position{};
float chance = 0;
Flip flip = FLIP_NONE;
WallSides sides = WALL_SIDES_NONE;
};
// One row of the start room's control icons, laid out from the left: each icon's button frame and position, the
// cursor the icons are drawn from, and the controller whose bindings they show.
struct ControlRow
{
std::vector<int> frames;
std::vector<float> positions;
float cursorX = 0;
float x = 0;
int controllerIndex = 0;
};
// Destruction (00932570) is the default.
// A room's background (Room's backdrop): the configs of backdrops.xml, and the walls, floor and water of the
// room's backdrop, drawn once into surfaces the room renders from.
struct Backdrop
{
std::array<BackdropConfig, BACKDROP_COUNT> configs;
KAGE::Graphics::ImagePtr floorBuffer;
KAGE::Graphics::ImagePtr floorSurface2;
KAGE::Graphics::ImagePtr gfx;
KAGE::Graphics::ImagePtr nlFloorGfx;
KAGE::Graphics::ImagePtr tempBackdropSurface;
KAGE::Graphics::ImagePtr wallsBuffer;
KAGE::Graphics::ImagePtr waterGfx;
ANM2 controlsButtonsSprite;
ANM2 controlsSprite;
ANM2 floorSprite;
ANM2 wallDetailSprite;
RNG rng = {};
Vector roomBottomRight{};
Vector roomTopLeft{};
uint32_t backdropId = 0;
uint32_t seed = 0;
bool isTempSurfaceUsed = false;
Backdrop();
bool LoadConfig(std::string_view path);
void Init(uint32_t id, bool isLoadGraphics);
uint32_t get_random_floor_variant();
DestinationQuad render_grid_rect(int x, int y, int width, int height);
void load_details();
void render_ashpit_ash();
void render_floor_to_target(uint32_t variant, const KAGE::Graphics::ImagePtr& sheet,
const KAGE::Graphics::ImagePtr& alternate);
void PreRenderControls();
void render_control_icon(ControlRow& row, int action);
void pre_render_walls();
void spawn_wall_details(const WallSlot& slot);
void render_wall_detail(const WallDetail& detail);
void RenderFloor(Vector renderOffset, ColorMod color);
void render_floor_surface(Vector renderOffset, ColorMod color);
void RenderWalls(Vector renderOffset, ColorMod color);
void render_wall_borders(Vector roomTopLeftPos, Vector roomSize);
void RenderWater(Vector renderOffset);
};
int controller_button_to_glyph_frame(int button);
Vector backdrop_detail_to_world_pos(Vector position);
Vector backdrop_wall_normal(int slotX, Flip flip);