Fix barrel group vertical centering calculation

- Correct baseY calculation to account for barrel centers
- baseY now positions bottom barrel so group center aligns with deck center
- Remove incorrect groupHeight calculation
- Both fuel and oil barrels now properly centered

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Thomas Richter
2025-12-17 05:02:34 +01:00
parent 95bb8f6e73
commit fb5b6a1dad

View File

@@ -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++) {