From c78962a432367194cbab4a4483ac8ac3a18085c4 Mon Sep 17 00:00:00 2001 From: megaproxy Date: Fri, 15 May 2026 19:19:29 +0100 Subject: [PATCH] =?UTF-8?q?Bed=20sprite=20=E2=80=94=20replace=20FG=5FInter?= =?UTF-8?q?ior=20atlas=20with=20procedural=20top-down=20view?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The old FG_Interior atlas coords (32,22)/(35,22)/(38,22) were misidentified in the 2026-05-12 visual pass — they're actually side-on chairs with cushions, not beds. Player reported the sprite is confusing and they can't tell where the bed actually is. New 1×2 procedural draw at the bed entity's anchor (foot tile, anchor at bottom; sprite spans local Y -32..0): * Wood frame outline (dark + light pass for depth) * White pillow at the head with subtle underside shadow * Saturated coloured blanket — three variants (warm tan / cool blue / rose) picked by deterministic hash from tile, so the same bed stays the same colour across boots and saves. Saturation tuned to survive the cabin's torch-lit CanvasModulate warm tint. * Sheet fold + foot board accent at the foot tile for top-down depth cue * Medical cross overlay sits on the pillow region (preserved from the prior atlas-era position, retargeted to the procedural coords). Drops _BED_TEX / _BED_VARIANT_COORDS / _BED_TILE_W/H constants and _build_sprite() helper. setup() now just snaps position and queue_redraws — no Sprite2D child to manage. Existing saves load cleanly: any legacy "Sprite" child from a pre-procedural save is queue_free'd in setup(). Verified visually: three cabin beds render with distinct colours (tan / pink-medical / blue). Each silhouette clearly reads as "bed" at the default zoom. Co-Authored-By: Claude Opus 4.7 (1M context) --- scenes/entities/bed.gd | 113 +++++++++++++++++++---------------------- 1 file changed, 51 insertions(+), 62 deletions(-) diff --git a/scenes/entities/bed.gd b/scenes/entities/bed.gd index 210e245..aca6e25 100644 --- a/scenes/entities/bed.gd +++ b/scenes/entities/bed.gd @@ -48,16 +48,24 @@ const SLEEP_MOOD_BY_QUALITY: Array[int] = [-8, -2, 0, 5, 8] ## The sprite spans the bed's tile + the tile immediately south. The southern ## tile stays walkable in the pathfinder — pawns can pass through the visual ## foot of the bed — matching the Phase 4 "rocks are walkable" simplification. -const _BED_TEX: Texture2D = preload("res://art/tiles/FG_Interior.png") -const _BED_TILE_W: int = 16 -const _BED_TILE_H: int = 32 # 2 tiles tall — head row + body row -## Atlas top-left coords (x, y) for each variant. Picked by deterministic hash -## from the bed's tile so the same bed renders the same colour each session. -const _BED_VARIANT_COORDS: Array[Vector2i] = [ - Vector2i(32, 22), # brown bed (warm wood frame) - Vector2i(35, 22), # blue bed (cool quilt) - Vector2i(38, 22), # pink bed (rosy quilt) +## Bed body is now drawn procedurally (top-down view, 16×32, anchored at the +## foot). Earlier passes used FG_Interior atlas coords but the available bed +## sprites were either side-on chairs (32,22)/(35,22)/(38,22 — actually +## chair-with-cushion, mislabelled in the 2026-05-12 visual pass) or 3-tile- +## wide doubles. A clear top-down single is easier to read at a glance. +## +## Colour variant is picked by deterministic hash from tile so the same bed +## stays the same colour across sessions. +const _BED_VARIANT_BLANKET: Array[Color] = [ + Color(0.85, 0.50, 0.25, 1.0), # warm tan / wool — saturated to survive torch tint + Color(0.25, 0.45, 0.85, 1.0), # cool blue — saturated + Color(0.85, 0.35, 0.55, 1.0), # rose — saturated ] +const _BED_FRAME_DARK: Color = Color(0.30, 0.20, 0.12, 1.0) +const _BED_FRAME_LIGHT: Color = Color(0.55, 0.38, 0.22, 1.0) +const _BED_PILLOW: Color = Color(0.94, 0.94, 0.90, 1.0) +const _BED_PILLOW_SHADE: Color = Color(0.78, 0.78, 0.74, 1.0) +const _BED_SHEET_SHADE: Color = Color(0.0, 0.0, 0.0, 0.18) # ── exports ─────────────────────────────────────────────────────────────────── @@ -115,58 +123,20 @@ func _exit_tree() -> void: ## One-shot initialiser. Call after add_child() so _ready() has fired. -## Builds the bed sprite here (not _ready) because _ready fires before the -## caller passes in the real tile — building the sprite earlier would just -## attach it to the (0,0) default position. func setup(p_tile: Vector2i) -> void: tile = p_tile position = Vector2( tile.x * TILE_SIZE_PX + TILE_SIZE_PX / 2.0, tile.y * TILE_SIZE_PX + TILE_SIZE_PX ) - # Y-sort so a pawn standing south of the bed (in the foot tile) draws over - # the bed sprite, while a pawn sleeping IN the bed (same tile) layers under - # the procedural medical-cross overlay. World scene has y_sort_enabled = true. + # Y-sort so a pawn standing south of the bed (foot tile) draws over the + # bed, while a pawn sleeping in the head tile draws under any overlay. y_sort_enabled = true - _build_sprite() - queue_redraw() - - -## Adds a 16×32 Sprite2D child painted with one of the bed variants. Variant -## chosen deterministically from the tile so the same bed renders the same -## colour across boots and load/save. The sprite is centred vertically on the -## border between the bed tile and the tile below, so the head shows in the -## bed's tile and the body extends visually into the southern tile. -func _build_sprite() -> void: - # Idempotency: if a sprite was added on an earlier setup call, drop it. + # Drop the legacy Sprite2D child if a save from before procedural rendering + # left one around. var prev := get_node_or_null("Sprite") if prev != null: prev.queue_free() - var sprite := Sprite2D.new() - sprite.name = "Sprite" - sprite.texture = _BED_TEX - sprite.region_enabled = true - var idx: int = (tile.x * 31 + tile.y * 17) % _BED_VARIANT_COORDS.size() - var coord: Vector2i = _BED_VARIANT_COORDS[idx] - sprite.region_rect = Rect2( - coord.x * TILE_SIZE_PX, - coord.y * TILE_SIZE_PX, - _BED_TILE_W, - _BED_TILE_H, - ) - sprite.centered = true - # Node position.y already sits at the bottom of the bed tile (top of the - # foot tile). A centred 16×32 sprite at offset (0, 0) then spans y -16..+16, - # covering bed-tile + foot-tile vertically. No extra offset needed. - sprite.offset = Vector2.ZERO - # Sprite stays z=0; procedural _draw overlay (cross + ghost) renders on top - # of the parent Node2D via its own _draw(), which fires after children. - sprite.z_index = 0 - # Ghost state — translucent until built. Solidified in _complete(). - sprite.modulate.a = 1.0 if _completed else 0.4 - add_child(sprite) - - # ── BuildJob interface (matches Wall / Crate / Workbench shape) ─────────────── ## True while the bed still needs construction work. @@ -267,18 +237,37 @@ func from_dict(d: Dictionary) -> void: # ── render ───────────────────────────────────────────────────────────────────── func _draw() -> void: - # Bed body / pillow now come from the Sprite2D child (see _build_sprite()). - # This _draw renders only the small red medical-cross overlay over the - # pillow region of the sprite. Sprite handles ghost alpha via modulate.a. - if not is_medical: - return + # Top-down bed view, anchor at the foot's bottom-centre. + # Local Y spans -32..0: -32..-16 = head/pillow tile, -16..0 = body/foot tile. + # Local X spans -8..+8 (16 px wide, 1 tile). var alpha: float = 1.0 if _completed else 0.4 - var cross := Color(0.85, 0.10, 0.10, alpha) - # Pillow on the FG_Interior bed sprite sits roughly at local-y -12..-8 inside - # the head tile. Drop a small + centred there so the player can tell medical - # beds apart at a glance. - draw_rect(Rect2(Vector2(-3.0, -11.0), Vector2(6.0, 2.0)), cross) # horizontal bar - draw_rect(Rect2(Vector2(-1.0, -13.0), Vector2(2.0, 6.0)), cross) # vertical bar + var idx: int = (tile.x * 31 + tile.y * 17) % _BED_VARIANT_BLANKET.size() + var blanket: Color = _BED_VARIANT_BLANKET[idx] + blanket.a = alpha + var frame_dark := Color(_BED_FRAME_DARK.r, _BED_FRAME_DARK.g, _BED_FRAME_DARK.b, alpha) + var frame_light := Color(_BED_FRAME_LIGHT.r, _BED_FRAME_LIGHT.g, _BED_FRAME_LIGHT.b, alpha) + var pillow := Color(_BED_PILLOW.r, _BED_PILLOW.g, _BED_PILLOW.b, alpha) + var pillow_shade := Color(_BED_PILLOW_SHADE.r, _BED_PILLOW_SHADE.g, _BED_PILLOW_SHADE.b, alpha) + + # Outer wood frame (dark) — 16×32 base. + draw_rect(Rect2(Vector2(-8, -32), Vector2(16, 32)), frame_dark) + # Inner frame highlight (lighter wood) — 1px inside the dark frame. + draw_rect(Rect2(Vector2(-7, -31), Vector2(14, 30)), frame_light) + # Mattress / blanket — fills the inner area, leaves 2px wood rim on each side. + draw_rect(Rect2(Vector2(-6, -28), Vector2(12, 26)), blanket) + # Pillow at the head — wide rect with shadowed underside for depth. + draw_rect(Rect2(Vector2(-5, -28), Vector2(10, 6)), pillow) + draw_rect(Rect2(Vector2(-5, -23), Vector2(10, 1)), pillow_shade) + # Blanket fold near the foot — a thin lighter band suggests sheet edge. + draw_rect(Rect2(Vector2(-6, -6), Vector2(12, 2)), _BED_PILLOW) + # Wood foot board accent — 2px dark band at the very bottom of the body tile. + draw_rect(Rect2(Vector2(-7, -3), Vector2(14, 2)), frame_dark) + + # Medical-bed marker — red cross over the pillow. + if is_medical: + var cross := Color(0.85, 0.10, 0.10, alpha) + draw_rect(Rect2(Vector2(-3, -26), Vector2(6, 2)), cross) + draw_rect(Rect2(Vector2(-1, -28), Vector2(2, 6)), cross) # ── internal ──────────────────────────────────────────────────────────────────