Visual pass 2: tree + rock + stone wall sprite swaps

Replaces three procedural _draw() entities with bundle sprites:

- Tree: was draw_rect trunk + draw_circle canopy. Now Sprite2D using
  FG_Tree_Spring.png (64x80, 4 variants picked deterministically from
  tile coord). Bottom-anchored so trunk base sits at tile bottom, canopy
  rises into the cell above; y_sort_enabled so canopies tuck behind
  pawns south of the trunk. Chop-progress notch overlay retained.
- Rock: was draw_colored_polygon hex. Now Sprite2D reading from the
  existing FG_Grasslands_Spring.png decoration atlas at three eyeballed
  coords (2 gray boulders, 1 brown rock pile). Variant deterministic
  per tile. Mine-progress crack overlay retained.
- Stone wall: was procedural top-band + front-band + mortar lines. Now
  Sprite2D from FG_Fortress.png at (1,1) — clean tan-stone brick fill.
  Bottom-anchored (offset.y=-8) so the 16x16 sprite spans y=-16..0,
  matching the procedural draw box exactly. Ghost state via modulate.a.
  Wood walls still use procedural _draw_wood_wall — no clean 16x16 wood
  tile found in the bundle yet (Pixel Crawler Walls.png is 32x32, would
  need crop+rescale).

Asset additions:
- art/sprites/FG_Tree_Spring.png (Tier 1, Grasslands pack)
- FG_Fortress.png and FG_Grasslands_Spring.png were already in art/tiles
  from earlier passes; this commit just consumes them from new sites.

Headless boots clean, runtime verified: trees look like chunky pixel-art
trees with root flare, rocks read as real boulders, cabin walls show
proper brick texture.

License: all ElvGames Humble bundle — commercial OK with credit.
Credit-string compilation still open.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
megaproxy 2026-05-12 14:19:06 +01:00
parent 314c7a70b4
commit 2de5130ae0
5 changed files with 145 additions and 51 deletions

View file

@ -27,14 +27,41 @@ var mine_progress: int = 0
# Preloaded scene for spawned stone items.
const ITEM_SCENE: PackedScene = preload("res://scenes/entities/item.tscn")
## Rock sprite atlas — re-uses the Grasslands tileset (already imported for the
## decoration overlay). The three coords below were eyeballed from the
## /tmp/rocks_review.png probe in the 2026-05-12 visual pass: two gray boulders
## and one brown rock for variety.
const _ROCK_TEX: Texture2D = preload("res://art/tiles/FG_Grasslands_Spring.png")
const _ROCK_VARIANT_COORDS: Array[Vector2i] = [
Vector2i(24, 7), # gray boulder A
Vector2i(28, 7), # gray boulder B
Vector2i(12, 13), # brown rock pile
]
# ── lifecycle ─────────────────────────────────────────────────────────────────
func _ready() -> void:
position = _tile_to_world(tile)
_build_sprite()
World.register_rock(self)
## Adds a Sprite2D child with one of the rock variants. Variant chosen
## deterministically from the tile coord so the same tile renders the same
## rock across boots and load/save.
func _build_sprite() -> void:
var sprite := Sprite2D.new()
sprite.name = "Sprite"
sprite.texture = _ROCK_TEX
sprite.region_enabled = true
var coord: Vector2i = _ROCK_VARIANT_COORDS[(tile.x * 31 + tile.y * 17) % _ROCK_VARIANT_COORDS.size()]
sprite.region_rect = Rect2(coord.x * TILE_SIZE_PX, coord.y * TILE_SIZE_PX, TILE_SIZE_PX, TILE_SIZE_PX)
sprite.centered = true
sprite.offset = Vector2.ZERO # 16×16 tile, sits centered on the tile
add_child(sprite)
func _exit_tree() -> void:
World.unregister_rock(self)
@ -99,35 +126,8 @@ static func from_dict(d: Dictionary) -> Dictionary:
# ── render ────────────────────────────────────────────────────────────────────
func _draw() -> void:
# Angular cluster of 34 triangles in a dark-grey / light-grey palette.
var c1 := Color(0.55, 0.55, 0.50) # light face
var c2 := Color(0.38, 0.38, 0.36) # shadow face
# Main body polygon (roughly an irregular hex).
var body := PackedVector2Array([
Vector2(-5.0, 3.0),
Vector2(-6.0, -1.0),
Vector2(-2.0, -6.0),
Vector2(3.0, -5.0),
Vector2(6.0, 0.0),
Vector2(4.0, 4.0),
])
draw_colored_polygon(body, c1)
# Shadow face on the bottom-right triangle to give depth.
var shadow := PackedVector2Array([
Vector2(3.0, -5.0),
Vector2(6.0, 0.0),
Vector2(4.0, 4.0),
Vector2(-5.0, 3.0),
])
draw_colored_polygon(shadow, c2)
# Outline.
draw_polyline(body, Color(0.0, 0.0, 0.0, 0.5), 1.0)
draw_line(body[5], body[0], Color(0.0, 0.0, 0.0, 0.5), 1.0)
# Mine-progress crack: a dark jagged line on the face when partially mined.
# Rock body comes from the Sprite2D child (see _build_sprite).
# This _draw renders only the mine-progress crack overlaid on the sprite.
if mine_progress > 0:
var ratio := float(mine_progress) / float(MINE_TICKS)
var crack_len := ratio * 5.0