Position barrels relative to deck dimensions
- Store deck dimensions as properties - Calculate deck boundaries (left, right, top, bottom) - Position fuel barrels relative to deck left edge - Position oil barrels relative to deck center - Both positioned relative to deck bottom 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -40,9 +40,21 @@ export default class ShipDeckScene extends Phaser.Scene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createDeck() {
|
createDeck() {
|
||||||
|
// Ship deck dimensions
|
||||||
|
this.deckCenterX = 400;
|
||||||
|
this.deckWidth = 700;
|
||||||
|
this.deckTopY = 200;
|
||||||
|
this.deckPlankSpacing = 30;
|
||||||
|
this.deckPlankCount = 8;
|
||||||
|
|
||||||
|
// Calculate deck boundaries
|
||||||
|
this.deckLeftX = this.deckCenterX - this.deckWidth / 2;
|
||||||
|
this.deckRightX = this.deckCenterX + this.deckWidth / 2;
|
||||||
|
this.deckBottomY = this.deckTopY + (this.deckPlankCount - 1) * this.deckPlankSpacing;
|
||||||
|
|
||||||
// Ship deck planks
|
// Ship deck planks
|
||||||
for (let i = 0; i < 8; i++) {
|
for (let i = 0; i < this.deckPlankCount; i++) {
|
||||||
this.add.rectangle(400, 200 + i * 30, 700, 25, 0x654321)
|
this.add.rectangle(this.deckCenterX, this.deckTopY + i * this.deckPlankSpacing, this.deckWidth, 25, 0x654321)
|
||||||
.setStrokeStyle(2, 0x3d2817);
|
.setStrokeStyle(2, 0x3d2817);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,8 +95,9 @@ export default class ShipDeckScene extends Phaser.Scene {
|
|||||||
const barrelCount = Math.ceil(this.inventory.fuel / 10);
|
const barrelCount = Math.ceil(this.inventory.fuel / 10);
|
||||||
if (barrelCount === 0) return;
|
if (barrelCount === 0) return;
|
||||||
|
|
||||||
const baseX = 120;
|
// Position relative to deck
|
||||||
const baseY = 450;
|
const baseX = this.deckLeftX + 70;
|
||||||
|
const baseY = this.deckBottomY + 40;
|
||||||
const barrelWidth = 50;
|
const barrelWidth = 50;
|
||||||
const barrelHeight = 70;
|
const barrelHeight = 70;
|
||||||
const horizontalSpacing = 60;
|
const horizontalSpacing = 60;
|
||||||
@@ -130,8 +143,9 @@ export default class ShipDeckScene extends Phaser.Scene {
|
|||||||
const barrelCount = Math.ceil(this.inventory.whaleOil / 10);
|
const barrelCount = Math.ceil(this.inventory.whaleOil / 10);
|
||||||
if (barrelCount === 0) return;
|
if (barrelCount === 0) return;
|
||||||
|
|
||||||
const baseX = 380;
|
// Position relative to deck
|
||||||
const baseY = 450;
|
const baseX = this.deckCenterX + 30;
|
||||||
|
const baseY = this.deckBottomY + 40;
|
||||||
const barrelWidth = 50;
|
const barrelWidth = 50;
|
||||||
const barrelHeight = 70;
|
const barrelHeight = 70;
|
||||||
const horizontalSpacing = 60;
|
const horizontalSpacing = 60;
|
||||||
|
|||||||
Reference in New Issue
Block a user