From 80b40855fd4ab6f9d19792e9b668cb6afd96c306 Mon Sep 17 00:00:00 2001 From: marco Date: Sat, 18 Sep 2021 19:07:27 -0600 Subject: [PATCH] #9, made it ready to display messages at different speed levels. Just needs to be adjusted according to what is desired. --- lib/firework.dart | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/firework.dart b/lib/firework.dart index 298dbf8..c9df46b 100644 --- a/lib/firework.dart +++ b/lib/firework.dart @@ -1,3 +1,5 @@ +import 'dart:math'; + import 'package:firo_runner/main.dart'; import 'package:flame/components.dart'; import 'package:flame/extensions.dart'; @@ -11,9 +13,26 @@ class Firework extends Component { late SpriteAnimationGroupComponent sprite2; Firework(this.gameRef); double timeSinceFirework = 0; + late Random random; String message = ""; + List messages = [ + "Speed Up!", + "Speed Up!", + "Speed Up!", + "Speed Up!", + "Speed Up!", + "Speed Up!", + "Speed Up!", + "Speed Up!", + "Speed Up!", + "Speed Up!", + "Speed Up!", + "Speed Up!", + "Speed Up!", + ]; Future load() async { + random = Random(); Image firework = await Flame.images.load("fireworks-frames.png"); SpriteAnimation normal = SpriteAnimation.fromFrameData( @@ -93,8 +112,7 @@ class Firework extends Component { } void reset() { - // message = gameRef.gameState.numCoins.toString(); - message = "Speed Up!"; + message = messages.elementAt(random.nextInt(messages.length)); sprite1.animation!.reset(); sprite2.animation!.reset(); }