refactor(arena): 아레나 화면 및 위젯 정리

This commit is contained in:
JiWoong Sul
2026-01-12 16:17:16 +09:00
parent a404c82f35
commit 104d23cdfd
8 changed files with 336 additions and 230 deletions

View File

@@ -11,9 +11,9 @@ class AsciiParticle {
required this.vx,
required this.vy,
required this.delay,
}) : x = initialX,
y = initialY,
opacity = 1.0;
}) : x = initialX,
y = initialY,
opacity = 1.0;
final String char;
final double initialX;
@@ -29,7 +29,10 @@ class AsciiParticle {
/// 진행도에 따라 파티클 상태 업데이트
void update(double progress) {
// 지연 적용
final adjustedProgress = ((progress - delay) / (1.0 - delay)).clamp(0.0, 1.0);
final adjustedProgress = ((progress - delay) / (1.0 - delay)).clamp(
0.0,
1.0,
);
if (adjustedProgress <= 0) {
// 아직 분해 시작 전
@@ -101,10 +104,7 @@ class _AsciiDisintegrateWidgetState extends State<AsciiDisintegrateWidget>
void initState() {
super.initState();
_initParticles();
_controller = AnimationController(
duration: widget.duration,
vsync: this,
)
_controller = AnimationController(duration: widget.duration, vsync: this)
..addListener(() => setState(() {}))
..addStatusListener((status) {
if (status == AnimationStatus.completed) {
@@ -129,16 +129,18 @@ class _AsciiDisintegrateWidgetState extends State<AsciiDisintegrateWidget>
final char = line[x];
// 공백은 파티클로 변환하지 않음
if (char != ' ') {
_particles.add(AsciiParticle(
char: char,
initialX: x.toDouble(),
initialY: y.toDouble(),
// 랜덤 속도 (위쪽 + 좌우로 퍼짐)
vx: (_random.nextDouble() - 0.5) * 4.0,
vy: -_random.nextDouble() * 2.0 - 0.5, // 위쪽으로
// 랜덤 지연 (안쪽에서 바깥쪽으로 분해)
delay: _random.nextDouble() * 0.3,
));
_particles.add(
AsciiParticle(
char: char,
initialX: x.toDouble(),
initialY: y.toDouble(),
// 랜덤 속도 (위쪽 + 좌우로 퍼짐)
vx: (_random.nextDouble() - 0.5) * 4.0,
vy: -_random.nextDouble() * 2.0 - 0.5, // 위쪽으로
// 랜덤 지연 (안쪽에서 바깥쪽으로 분해)
delay: _random.nextDouble() * 0.3,
),
);
}
}
}
@@ -158,9 +160,9 @@ class _AsciiDisintegrateWidgetState extends State<AsciiDisintegrateWidget>
size: Size(
widget.characterLines.isNotEmpty
? widget.characterLines
.map((l) => l.length)
.reduce((a, b) => a > b ? a : b) *
widget.charWidth
.map((l) => l.length)
.reduce((a, b) => a > b ? a : b) *
widget.charWidth
: 0,
widget.characterLines.length * widget.charHeight,
),