Fix item shapes: mod sprites need an opaque pixel at the centre of every cell
The game decides which cells an item occupies by the alpha of one pixel at the centre of each 16x16 cell. The rig's rack bays left gaps exactly on the centre rows, so 8 of 9 cells counted as empty and other items were placed underneath it; the terminal's stand did the same. The rig gets a solid back plate, the terminal's stand is widened, and art/sprites.py now checks every cell the way the game does and refuses to write a sprite with a hole. Verified in game: new rigs are 3x3 solid, new terminals 2x2 solid. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1841338fbb
commit
a2a4d12ad3
6 files changed
+19
-4
No files matched your search
Binary file not shown.
+16
-4
@@ -110,7 +110,7 @@ def gpu(accent, accent_dark, burnt=False):
|
||||
def rig():
|
||||
"""矿架(48×48,3×3 格):开放式机架,四层显卡位,左下电源。"""
|
||||
c = Canvas(48, 48)
|
||||
c.box(2, 3, 45, 44, None)
|
||||
c.box(2, 3, 45, 44, 'd') # 外框 + 背板:内部不透明,否则游戏按格子中心像素判断占格会把空隙当成空格
|
||||
for y in range(4, 44):
|
||||
c.put(3, y, 'b'); c.put(44, y, 'd')
|
||||
for x in range(3, 45):
|
||||
@@ -139,7 +139,7 @@ def terminal():
|
||||
for x, top, bot in candles:
|
||||
c.rect(x, top, x, bot, 'S')
|
||||
c.put(x, top - 1, 'T')
|
||||
c.rect(13, 22, 18, 23, 'd') # 支架
|
||||
c.rect(3, 22, 28, 23, 'd') # 支架(拉通,保证每格中心点不透明)
|
||||
c.box(2, 24, 29, 30, 'b') # 键盘
|
||||
for y in (26, 28):
|
||||
for x in range(4, 28, 2):
|
||||
@@ -155,14 +155,26 @@ SPRITES = {
|
||||
'terminal': terminal,
|
||||
}
|
||||
|
||||
def check_cells(canvas, name):
|
||||
"""游戏按 mod 物品图每格的中心像素是否不透明来判断占格(行从图的下沿往上数)。有空格就报错。"""
|
||||
cols, rows = canvas.w // 16, canvas.h // 16
|
||||
bad = [(q, r) for r in range(rows) for q in range(cols) if canvas.px[canvas.h - 1 - (r * 16 + 8)][q * 16 + 8] is None]
|
||||
if bad:
|
||||
raise SystemExit(f"{name}: 这些格子中心像素透明(游戏会当成空格,别的物品会叠上来):{bad}")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
here = os.path.dirname(os.path.abspath(__file__))
|
||||
if len(sys.argv) == 3 and sys.argv[1] == '--preview':
|
||||
for name, make in SPRITES.items():
|
||||
make().png(os.path.join(sys.argv[2], name + '.png'), scale=6, bg=(0xA0, 0xA8, 0x9C))
|
||||
canvas = make()
|
||||
check_cells(canvas, name)
|
||||
canvas.png(os.path.join(sys.argv[2], name + '.png'), scale=6, bg=(0xA0, 0xA8, 0x9C))
|
||||
print(sys.argv[2])
|
||||
else:
|
||||
out = os.path.normpath(os.path.join(here, '..', 'src', 'Decentralized', 'ModFiles', 'Textures', 'Items'))
|
||||
for name, make in SPRITES.items():
|
||||
make().png(os.path.join(out, name + '.png'))
|
||||
canvas = make()
|
||||
check_cells(canvas, name)
|
||||
canvas.png(os.path.join(out, name + '.png'))
|
||||
print(out)
|
||||
Reference in new issue
Block a user