Skip to content

Commit f32697c

Browse files
committed
Avoid plate 'on' sprite bleeding under box
Detect when a push-box sits on an active pressure plate and use the plate's inactive sprite to prevent the plate's border pixels from bleeding through the box's transparent edges. Adds an optional resetPushBoxesForRoom method to the GameState API and calls it when the player exits a room to reset push-box state for the current room before updating the player's position.
1 parent 7e7ad05 commit f32697c

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎src/runtime/adapters/renderer/RendererEntityRenderer.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,12 @@ class RendererEntityRenderer {
145145
const isActive = object.variableId
146146
? this.gameState.isVariableOn?.(object.variableId) ?? false
147147
: Boolean(object.activated);
148-
sprite = (isActive ? objectSprites[`${object.type}--on`] : objectSprites[object.type]) || sprite;
148+
// A push-box at the same tile covers the plate — use inactive sprite so the
149+
// plate's border pixels don't bleed through the box's transparent edges.
150+
const boxOnPlate = isActive && objects.some(
151+
(o) => o.type === OT.PUSH_BOX && o.roomIndex === object.roomIndex && o.x === object.x && o.y === object.y
152+
);
153+
sprite = (isActive && !boxOnPlate ? objectSprites[`${object.type}--on`] : objectSprites[object.type]) || sprite;
149154
}
150155
if (object.type === OT.TRAP) {
151156
const isActive = object.variableId

‎src/runtime/services/engine/InteractionManager.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ type GameStateApi = {
9696
showPickupOverlay?: (payload: Record<string, unknown>) => void;
9797
setPlayerPosition: (x: number, y: number, roomIndex: number | null) => void;
9898
getRoomIndex: (row: number, col: number) => number | null;
99+
resetPushBoxesForRoom?: (roomIndex: number) => void;
99100
};
100101

101102
type Options = {
@@ -499,6 +500,7 @@ class InteractionManager {
499500
if (!sameTile) continue;
500501

501502
if (rooms[exit.targetRoomIndex]) {
503+
this.gameState.resetPushBoxesForRoom?.(player.roomIndex);
502504
this.gameState.setPlayerPosition(
503505
this.clamp(exit.targetX, 0, 7),
504506
this.clamp(exit.targetY, 0, 7),

0 commit comments

Comments
 (0)