feat: add depth to game

This commit is contained in:
2026-06-15 19:40:25 +03:30
parent fbf068c2e6
commit 73b7c136f1
4 changed files with 117 additions and 16 deletions
@@ -106,6 +106,14 @@ class CardComponent extends PositionComponent
final radius = Radius.circular(size.x * 0.09);
final rrect = RRect.fromRectAndRadius(rect, radius);
// سایه‌ی سبک و ارزان (بدون blurِ هر-فریمی) فقط برای کارت‌های رو ⇒ عمق بدون افت کارایی.
// (drawShadow هر فریم برای ده‌ها کارت بسیار سنگین بود و باعث لگ می‌شد.)
if (faceUp) {
final off = _dragging ? size.x * 0.10 : size.x * 0.03;
canvas.drawRRect(rrect.shift(Offset(off * 0.4, off)),
Paint()..color = Color(_dragging ? 0x66000000 : 0x44000000));
}
if (_sprite != null) {
canvas.save();
canvas.clipRRect(rrect);
@@ -117,6 +125,22 @@ class CardComponent extends PositionComponent
_drawVectorBack(canvas, rrect);
}
// براقیتِ ملایم از بالا فقط برای کارت‌های رو.
if (faceUp) {
canvas.save();
canvas.clipRRect(rrect);
canvas.drawRect(
Rect.fromLTWH(0, 0, size.x, size.y * 0.5),
Paint()
..shader = const LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Color(0x2BFFFFFF), Color(0x00FFFFFF)],
).createShader(Rect.fromLTWH(0, 0, size.x, size.y * 0.5)),
);
canvas.restore();
}
if (dimmed) {
canvas.drawRRect(rrect, Paint()..color = const Color(0x73000000));
}