Skip to content

Commit 7eaded0

Browse files
committed
Rotate Left/Right cards to landscape mode with 90-degree base angle
1 parent 56a92a9 commit 7eaded0

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

playing-cards-2-planes/Left.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import { Container } from 'pixi.js';
99
import { Tween, Easing } from '@tweenjs/tween.js';
10-
import { Card, CARD_WIDTH, CARD_HEIGHT, TWEEN_DURATION, CARD_VISIBLE_RATIO } from './Card.js';
10+
import { Card, CARD_WIDTH, TWEEN_DURATION, CARD_VISIBLE_RATIO } from './Card.js';
1111

1212
/**
1313
* Left container for displaying opponent cards in a vertical column on the left edge.
@@ -104,10 +104,11 @@ export class Left extends Container {
104104
cards.forEach((card) => this.addChild(card));
105105

106106
const totalCards = cards.length;
107-
const minPaddingToScreenEdge = CARD_HEIGHT / 3;
108-
const maxSpacingBetweenCards = CARD_HEIGHT * CARD_VISIBLE_RATIO;
107+
// Use CARD_WIDTH for spacing since cards are rotated 90 degrees
108+
const minPaddingToScreenEdge = CARD_WIDTH / 3;
109+
const maxSpacingBetweenCards = CARD_WIDTH * CARD_VISIBLE_RATIO;
109110

110-
const availableHeight = this._screen.height - 2 * minPaddingToScreenEdge - CARD_HEIGHT;
111+
const availableHeight = this._screen.height - 2 * minPaddingToScreenEdge - CARD_WIDTH;
111112
const spacingBetweenCards = Math.min(maxSpacingBetweenCards, availableHeight / (totalCards - 1));
112113

113114
const totalCardsHeight = (totalCards - 1) * spacingBetweenCards;
@@ -126,8 +127,8 @@ export class Left extends Container {
126127
// Hover direction: push left (negative X)
127128
card.hoverDirX = -1;
128129
card.hoverDirY = 0;
129-
// Tilt: cards at top tilt left (-), cards at bottom tilt right (+)
130-
card.angle = (index - middleIndex) * 1;
130+
// Base 90 degrees for landscape mode, plus tilt: cards at top tilt left (-), cards at bottom tilt right (+)
131+
card.angle = 90 + (index - middleIndex) * 1;
131132
});
132133
}
133134
}

playing-cards-2-planes/Right.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import { Container } from 'pixi.js';
99
import { Tween, Easing } from '@tweenjs/tween.js';
10-
import { Card, CARD_WIDTH, CARD_HEIGHT, TWEEN_DURATION, CARD_VISIBLE_RATIO } from './Card.js';
10+
import { Card, CARD_WIDTH, TWEEN_DURATION, CARD_VISIBLE_RATIO } from './Card.js';
1111

1212
/**
1313
* Right container for displaying opponent cards in a vertical column on the right edge.
@@ -104,10 +104,11 @@ export class Right extends Container {
104104
cards.reverse().forEach((card) => this.addChild(card));
105105

106106
const totalCards = cards.length;
107-
const minPaddingToScreenEdge = CARD_HEIGHT / 3;
108-
const maxSpacingBetweenCards = CARD_HEIGHT * CARD_VISIBLE_RATIO;
107+
// Use CARD_WIDTH for spacing since cards are rotated 90 degrees
108+
const minPaddingToScreenEdge = CARD_WIDTH / 3;
109+
const maxSpacingBetweenCards = CARD_WIDTH * CARD_VISIBLE_RATIO;
109110

110-
const availableHeight = this._screen.height - 2 * minPaddingToScreenEdge - CARD_HEIGHT;
111+
const availableHeight = this._screen.height - 2 * minPaddingToScreenEdge - CARD_WIDTH;
111112
const spacingBetweenCards = Math.min(maxSpacingBetweenCards, availableHeight / (totalCards - 1));
112113

113114
const totalCardsHeight = (totalCards - 1) * spacingBetweenCards;
@@ -126,8 +127,8 @@ export class Right extends Container {
126127
// Hover direction: push right (positive X)
127128
card.hoverDirX = 1;
128129
card.hoverDirY = 0;
129-
// Tilt: mirrored - cards at top tilt right (+), cards at bottom tilt left (-)
130-
card.angle = -(index - middleIndex) * 1;
130+
// Base -90 degrees for landscape mode, plus tilt: mirrored - cards at top tilt right (+), cards at bottom tilt left (-)
131+
card.angle = -90 - (index - middleIndex) * 1;
131132
});
132133
}
133134
}

0 commit comments

Comments
 (0)