diff --git a/src/scenes/ShipDeckScene.js b/src/scenes/ShipDeckScene.js index a90f684..31cc0be 100644 --- a/src/scenes/ShipDeckScene.js +++ b/src/scenes/ShipDeckScene.js @@ -115,7 +115,6 @@ export default class ShipDeckScene extends Phaser.Scene { // 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); @@ -123,7 +122,12 @@ export default class ShipDeckScene extends Phaser.Scene { // Center vertically on deck (using actual deck edges) const deckVerticalCenter = (this.deckTopEdge + this.deckBottomEdge) / 2; - const baseY = deckVerticalCenter + (groupHeight / 2); + // Calculate where bottom barrel should be so group is centered + // Top of group = baseY - (stackLevels-1)*verticalSpacing - barrelHeight/2 + // Bottom of group = baseY + barrelHeight/2 + // Center of group = (top + bottom) / 2 = baseY - ((stackLevels-1)*verticalSpacing)/2 + // We want: baseY - ((stackLevels-1)*verticalSpacing)/2 = deckVerticalCenter + const baseY = deckVerticalCenter + ((stackLevels - 1) * verticalSpacing) / 2; // Create barrels in stacking pattern for (let i = 0; i < barrelCount; i++) { @@ -191,7 +195,6 @@ export default class ShipDeckScene extends Phaser.Scene { // 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); @@ -199,7 +202,8 @@ export default class ShipDeckScene extends Phaser.Scene { // Center vertically on deck (using actual deck edges) const deckVerticalCenter = (this.deckTopEdge + this.deckBottomEdge) / 2; - const baseY = deckVerticalCenter + (groupHeight / 2); + // Calculate where bottom barrel should be so group is centered + const baseY = deckVerticalCenter + ((stackLevels - 1) * verticalSpacing) / 2; // Create barrels in stacking pattern for (let i = 0; i < barrelCount; i++) {