feat: add game graphic

This commit is contained in:
2026-07-08 09:06:32 +03:30
parent ffd2646eea
commit 46a649166b
15 changed files with 521 additions and 57 deletions
@@ -8,6 +8,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart' show HapticFeedback;
import '../../../../../core/service/app_sounds.dart';
import '../../../../../core/settings/app_settings.dart';
import '../../../../../core/theme/app_theme.dart';
import '../../../domain/entities/game_entities.dart';
import '../../bloc/game_bloc.dart';
@@ -84,6 +85,9 @@ class HokmGame extends FlameGame {
@override
Future<void> onLoad() async {
add(Felt(carpet: carpet));
if (!AppSettings.I.lowGraphics.value) {
add(Motes()); // ذراتِ طلاییِ معلق برای اتمسفر (در حالتِ کم‌مصرف خاموش)
}
_sub = cubit.stream.listen((ui) {
if (ui.state == null) return;
final s = ui.state!;
@@ -172,6 +176,9 @@ class HokmGame extends FlameGame {
_bestTrumpRank = rank;
_shake = 1.0;
add(Lightning());
if (!AppSettings.I.lowGraphics.value) {
add(CutBurst()); // فلاش + شوک‌ویو + جرقه (کم‌مصرف: خاموش)
}
AppSounds.cut(); // بریدن با حکم (شمشیر)
HapticFeedback.heavyImpact(); // ضربه‌ی لمسیِ بُرِش با حکم
} else {
@@ -379,7 +386,8 @@ class HokmGame extends FlameGame {
}
// حرکتِ نرمِ یک کارت به مقصد، بدون انباشته‌شدنِ افکت‌ها.
void _moveTo(CardComponent c, Vector2 target, {double dur = 0.38}) {
void _moveTo(CardComponent c, Vector2 target,
{double dur = 0.38, bool bounce = false}) {
c.children.whereType<MoveToEffect>().toList().forEach(
(e) => e.removeFromParent(),
);
@@ -387,10 +395,12 @@ class HokmGame extends FlameGame {
c.position = target;
return;
}
// کارتِ تازه‌نشسته روی میز با کمی overshoot می‌نشیند (حسِ «جا افتادن»).
c.add(
MoveToEffect(
target,
EffectController(duration: dur, curve: Curves.easeOutCubic),
EffectController(
duration: dur, curve: bounce ? Curves.easeOutBack : Curves.easeOutCubic),
),
);
}
@@ -507,6 +517,7 @@ class HokmGame extends FlameGame {
for (final tc in s.trick) {
final slot = size / 2 + _trickOffset(_rel(tc.seat));
var c = _trick[tc.card];
final isNew = c == null; // فقط کارتِ تازه‌نشسته bounce می‌شود
if (c == null) {
// اگر خودِ شما بازی کردید، همان کارتِ دست را منتقل کن (پرواز به وسط).
c = _hand.remove(tc.card);
@@ -530,7 +541,7 @@ class HokmGame extends FlameGame {
c.size = Vector2(_cardW, _cardH);
c.angle = 0; // کارت‌های روی زمین صاف‌اند (چرخشِ بادبزنیِ دست حذف می‌شود)
c.priority = 5;
_moveTo(c, slot);
_moveTo(c, slot, bounce: isNew);
}
// دستِ کامل (۴ کارت) ⇒ کارتِ برنده را طلایی هایلایت کن و یک‌بار «پاپ» بزن،