Skip to content

Commit 87b800b

Browse files
committed
Introduce CARD_MAX_TABLE_ANGLE const
1 parent 33b15fa commit 87b800b

File tree

3 files changed

+16
-20
lines changed

3 files changed

+16
-20
lines changed

playing-cards-2-planes/Card.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ export const CARD_VISIBLE_RATIO = 0.3;
2727
/** @constant {number} Distance cards move on hover */
2828
export const HOVER_DISTANCE = 40;
2929

30+
/** @constant {number} Maximum angle for cards on the table */
31+
export const CARD_MAX_TABLE_ANGLE = 20;
32+
3033
/**
3134
* Represents a playing card that can be displayed and animated.
3235
* Cards can be placed in Hand, Table, Left, or Right containers.
@@ -210,10 +213,7 @@ export class Card extends Container {
210213
.chain(
211214
new Tween(this, Card.tweenGroup)
212215
.to({ [prop]: original - 10 }, 50)
213-
.chain(
214-
new Tween(this, Card.tweenGroup)
215-
.to({ [prop]: original }, 50)
216-
)
216+
.chain(new Tween(this, Card.tweenGroup).to({ [prop]: original }, 50))
217217
)
218218
.start();
219219
}

playing-cards-2-planes/Table.js

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

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

1212
/**
1313
* Table container for displaying cards in the center play area.
@@ -72,7 +72,7 @@ export class Table extends Container {
7272
// Card positions are at center, so add half card size to keep cards fully inside
7373
this._bounds.minX = paddingX + CARD_WIDTH / 3;
7474
this._bounds.maxX = this._screen.width - paddingX - CARD_WIDTH / 3;
75-
this._bounds.minY = paddingY + CARD_HEIGHT / 2;
75+
this._bounds.minY = paddingY + CARD_HEIGHT / 3;
7676
this._bounds.maxY = this._screen.height - paddingY - (2 * CARD_HEIGHT) / 3;
7777

7878
this._drawBounds();
@@ -128,12 +128,7 @@ export class Table extends Container {
128128

129129
for (let i = 0; i < this._quadrantCards.length; i++) {
130130
const qb = this._getQuadrantBounds(i);
131-
this._boundsGraphics.rect(
132-
qb.minX,
133-
qb.minY,
134-
qb.maxX - qb.minX,
135-
qb.maxY - qb.minY
136-
);
131+
this._boundsGraphics.rect(qb.minX, qb.minY, qb.maxX - qb.minX, qb.maxY - qb.minY);
137132
this._boundsGraphics.stroke({ width: 2, color: 0xff0000 });
138133
}
139134
}
@@ -182,17 +177,17 @@ export class Table extends Container {
182177
// CCW is negative in Pixi.js, CW is positive
183178
let angle;
184179
switch (quadrantIndex) {
185-
case 0: // top-left: CCW 0 to 20 (angle -20 to 0)
186-
angle = Math.random() * -20;
180+
case 0: // top-left: CW 0 to CARD_MAX_TABLE_ANGLE
181+
angle = Math.random() * CARD_MAX_TABLE_ANGLE;
187182
break;
188-
case 1: // top-right: CW 0 to 20 (angle 0 to 20)
189-
angle = Math.random() * 20;
183+
case 1: // top-right: CCW 0 to CARD_MAX_TABLE_ANGLE
184+
angle = Math.random() * -CARD_MAX_TABLE_ANGLE;
190185
break;
191-
case 2: // bottom-left: CW 0 to 20 (angle 0 to 20)
192-
angle = Math.random() * 20;
186+
case 2: // bottom-left: CCW 0 to CARD_MAX_TABLE_ANGLE
187+
angle = Math.random() * -CARD_MAX_TABLE_ANGLE;
193188
break;
194-
case 3: // bottom-right: CCW 0 to 20 (angle -20 to 0)
195-
angle = Math.random() * -20;
189+
case 3: // bottom-right: CCW 0 to CARD_MAX_TABLE_ANGLE
190+
angle = Math.random() * -CARD_MAX_TABLE_ANGLE;
196191
break;
197192
default:
198193
angle = 0;

playing-cards-2-planes/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"dev": "vite",
99
"build": "vite build",
1010
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
11+
"lint:fix": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0 --fix",
1112
"preview": "vite preview",
1213
"test": "vitest",
1314
"test:ui": "vitest --ui",

0 commit comments

Comments
 (0)