Add multi-cell box shapes with per-cell collision
Generate 1x2/2x1 dominoes, 2x2 (square + 4 L-trominoes) and all
connected 3x2/2x3 polyominoes as R/G/B channel masks, reusing the
distance-based concentric-ring format that reproduces box_r/g/b
exactly. Outer silhouette keeps a 1px margin; connected cells stay
seamless. Each shape ships a {class="moveable"} .meta so getAllAssets
auto-registers it as a GenericMoveable.
Wire the occupied-cell shape (precomputed once by getAllAssets via
getCellsFromSprite) through to entities: createEntity now passes the
cached cells as cellShape, so an L/U/notched block collides on its real
cells and its gaps read as empty space. Fix the per-colour cache that
was reset every channel so only one colour survived.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
5b7ea9ec20
commit
d96f57efb6
154 changed files with 194 additions and 9 deletions
9
room.lua
9
room.lua
|
|
@ -570,10 +570,15 @@ function Room:createEntity(class, color, x, y)
|
|||
self:setActiveColor(color, true)
|
||||
elseif props and props.sprites and props.sprites[color] then
|
||||
local sprite = loadSprite(props.sprites[color])
|
||||
-- Reuse the cell shape precomputed by getAllAssets (nil/empty falls back
|
||||
-- to the full sprite rectangle inside Entity), so an L/U/notched block
|
||||
-- collides on its real cells and its gaps read as empty space.
|
||||
local cellShape = props.cells and props.cells[color]
|
||||
if cellShape and #cellShape == 0 then cellShape = nil end
|
||||
if behavior == "moveable" then
|
||||
entity = GenericMoveable:new(x, y, color, sprite, class)
|
||||
entity = GenericMoveable:new(x, y, color, sprite, class, cellShape)
|
||||
else
|
||||
entity = GenericUnmoveable:new(x, y, color, sprite)
|
||||
entity = GenericUnmoveable:new(x, y, color, sprite, cellShape)
|
||||
end
|
||||
self:registerCollidable(entity, {color})
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue