diff --git a/src/scenes/ShipDeckScene.js b/src/scenes/ShipDeckScene.js index a0e7082..d92403d 100644 --- a/src/scenes/ShipDeckScene.js +++ b/src/scenes/ShipDeckScene.js @@ -101,11 +101,18 @@ export default class ShipDeckScene extends Phaser.Scene { const verticalSpacing = 75; const barrelsPerRow = 5; - // Calculate group width and center it in left half of deck + // Calculate group dimensions const groupWidth = (Math.min(barrelCount, barrelsPerRow) * horizontalSpacing); + const stackLevels = Math.ceil(barrelCount / barrelsPerRow); + const groupHeight = (stackLevels * barrelHeight) + ((stackLevels - 1) * (verticalSpacing - barrelHeight)); + + // Center horizontally in left half of deck const leftHalfCenter = this.deckLeftX + (this.deckWidth / 4); const baseX = leftHalfCenter - (groupWidth / 2) + (horizontalSpacing / 2); - const baseY = this.deckBottomY - 10; + + // Center vertically on deck + const deckVerticalCenter = this.deckTopY + ((this.deckBottomY - this.deckTopY) / 2); + const baseY = deckVerticalCenter + (groupHeight / 2); // Create barrels in stacking pattern for (let i = 0; i < barrelCount; i++) { @@ -152,11 +159,18 @@ export default class ShipDeckScene extends Phaser.Scene { const verticalSpacing = 75; const barrelsPerRow = 3; - // Calculate group width and center it in right half of deck + // Calculate group dimensions const groupWidth = (Math.min(barrelCount, barrelsPerRow) * horizontalSpacing); + const stackLevels = Math.ceil(barrelCount / barrelsPerRow); + const groupHeight = (stackLevels * barrelHeight) + ((stackLevels - 1) * (verticalSpacing - barrelHeight)); + + // Center horizontally in right half of deck const rightHalfCenter = this.deckCenterX + (this.deckWidth / 4); const baseX = rightHalfCenter - (groupWidth / 2) + (horizontalSpacing / 2); - const baseY = this.deckBottomY - 10; + + // Center vertically on deck + const deckVerticalCenter = this.deckTopY + ((this.deckBottomY - this.deckTopY) / 2); + const baseY = deckVerticalCenter + (groupHeight / 2); // Create barrels in stacking pattern for (let i = 0; i < barrelCount; i++) {