Skip to content

Commit

Permalink
πŸ‘ γ‚γŸγ‚ŠζΌ”ε‡ΊθΏ½εŠ 
Browse files Browse the repository at this point in the history
  • Loading branch information
dicenull committed Sep 9, 2023
1 parent 101ed6c commit 76341d9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
23 changes: 22 additions & 1 deletion lib/feature_slot/reel_component.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:app/feature_slot/slot_core.dart';
import 'package:app/feature_slot/slot_symbol.dart';
import 'package:flame/components.dart';
import 'package:flame/effects.dart';
import 'package:flame/flame.dart';
import 'package:flame/palette.dart';
import 'package:flame_audio/flame_audio.dart';
Expand Down Expand Up @@ -55,16 +56,36 @@ class ReelComponent extends PositionComponent
));
});
}

SequenceEffect get hitEffect => SequenceEffect([
ColorEffect(
const Color(0xFFFFFFFF),
const Offset(0.0, 0.5),
EffectController(duration: 1, curve: Curves.bounceOut),
),
ColorEffect(
const Color(0xFFFFFFFF),
const Offset(0.5, 0),
EffectController(duration: 0.1, startDelay: 1),
),
]);
int get length => _symbols.length;

Vector2 get reelCenter => Vector2(symbolSize, visibleReelHeight) * .5;

double get visibleReelHeight => symbolSize * 3;

SlotSymbol? get _suberiSymbol =>
(stopIndex != -1) ? _reel[stopIndex].symbol : null;

double calcDrawHeight(int y) =>
(symbolSize * y + reelPosition) % reelHeight - reelHeight * .5;

void hit(int pos) {
final hitIndex = (pos - 1 + stopIndex + _reel.length) % _reel.length;

_reel[hitIndex].sprite.add(hitEffect);
}

@override
void render(Canvas canvas) {
final reelRange = Rect.fromCenter(
Expand Down
4 changes: 4 additions & 0 deletions lib/feature_slot/slot_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ class SlotComponent extends PositionComponent with HasGameRef<SlotGame> {

gameRef.addPoint(l);
rollStream.add(SlotEvent.smallBonus);

reels[0].hit(x);
reels[1].hit(y);
reels[2].hit(z);
}
}

Expand Down

0 comments on commit 76341d9

Please sign in to comment.