diff --git a/assets/images/bg.png b/assets/images/bg.png index 25cea32..9d9278b 100644 Binary files a/assets/images/bg.png and b/assets/images/bg.png differ diff --git a/assets/images/bug-break-frames.png b/assets/images/bug-break-frames.png index a10bf97..d43efba 100644 Binary files a/assets/images/bug-break-frames.png and b/assets/images/bug-break-frames.png differ diff --git a/lib/Bug.dart b/lib/Bug.dart index 951d9f3..814c1ee 100644 --- a/lib/Bug.dart +++ b/lib/Bug.dart @@ -20,7 +20,7 @@ class Bug extends MovingObject { SpriteAnimation breaking = SpriteAnimation.fromFrameData( breakingImage, SpriteAnimationData.sequenced( - amount: 12, + amount: 13, stepTime: 0.01, textureSize: Vector2(512, 512), loop: false, diff --git a/lib/main.dart b/lib/main.dart index 814da69..471ddf3 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -19,6 +19,7 @@ import 'package:flutter/services.dart'; import 'Bug.dart'; import 'Coin.dart'; import 'Runner.dart'; +import 'package:flutter/foundation.dart' show kIsWeb; const COLOR = const Color(0xFFDDC0A3); @@ -47,6 +48,7 @@ class MyGame extends BaseGame with PanDetector, TapDetector, KeyboardEvents { late WireHolder wireHolder; late BugHolder bugHolder; Random random = Random(); + bool playingMusic = false; late Runner runner; late GameState gameState; @@ -77,11 +79,18 @@ class MyGame extends BaseGame with PanDetector, TapDetector, KeyboardEvents { runner = Runner(); await runner.load(loadSpriteAnimation); - FlameAudio.bgm.play('Infinite_Spankage_M.mp3'); + if (!kIsWeb) { + playMusic(); + } loaded = true; setUp(); } + void playMusic() { + FlameAudio.bgm.play('Infinite_Spankage_M.mp3'); + playingMusic = true; + } + void fillScreen() { if (shouldReset) { return; @@ -236,6 +245,9 @@ class MyGame extends BaseGame with PanDetector, TapDetector, KeyboardEvents { @override void onPanEnd(DragEndInfo info) { + if (!playingMusic && kIsWeb) { + playMusic(); + } double xDelta = xDeltas.isEmpty ? 0 : xDeltas.reduce((value, element) => value + element); @@ -259,6 +271,9 @@ class MyGame extends BaseGame with PanDetector, TapDetector, KeyboardEvents { @override void onTap() { + if (!playingMusic && kIsWeb) { + playMusic(); + } runner.control("center"); } @@ -266,6 +281,9 @@ class MyGame extends BaseGame with PanDetector, TapDetector, KeyboardEvents { var keyboardKey; @override void onKeyEvent(RawKeyEvent event) { + if (!playingMusic && kIsWeb) { + playMusic(); + } if (event is RawKeyUpEvent) { keyboardKey = null; switch (event.data.keyLabel) {