diff --git a/assets/audio/Bones.mp3 b/assets/audio/Bones.mp3 deleted file mode 100644 index 160f39f..0000000 Binary files a/assets/audio/Bones.mp3 and /dev/null differ diff --git a/assets/audio/gameover.wav b/assets/audio/gameover.wav deleted file mode 100644 index 047b030..0000000 Binary files a/assets/audio/gameover.wav and /dev/null differ diff --git a/assets/audio/hit.mp3 b/assets/audio/hit.mp3 deleted file mode 100644 index 4d20b33..0000000 Binary files a/assets/audio/hit.mp3 and /dev/null differ diff --git a/assets/audio/point.mp3 b/assets/audio/point.mp3 deleted file mode 100644 index 462f96e..0000000 Binary files a/assets/audio/point.mp3 and /dev/null differ diff --git a/lib/Constant/constant.dart b/lib/Constant/constant.dart index dde77ef..c024a70 100644 --- a/lib/Constant/constant.dart +++ b/lib/Constant/constant.dart @@ -51,20 +51,6 @@ Duration duration = Duration.zero; Duration position = Duration.zero; -/////////////////// GameOver audio -final audio2 = AudioPlayer(); -bool isPlaying2 = false; -Duration duration2 = Duration.zero; -Duration position2 = Duration.zero; - - - -//////////////////// Point audio -final audio3 = AudioPlayer(); -bool isPlaying3 = false; -Duration duration3 = Duration.zero; -Duration position3 = Duration.zero; - /// to decide which page that class [Button] will navigate enum Navigation{ home, settings, leaderBord } diff --git a/lib/Layouts/Pages/page_home.dart b/lib/Layouts/Pages/page_home.dart index 9ec6401..ffcc0e5 100644 --- a/lib/Layouts/Pages/page_home.dart +++ b/lib/Layouts/Pages/page_home.dart @@ -41,46 +41,6 @@ class _HomePageState extends State { }); }); -//////////////////// audio2 - setAudio2(); - audio2.onAudioPositionChanged.listen((state) { - setState(() { - isPlaying2 = state == PlayerState.PLAYING; - }); - }); - - audio2.onDurationChanged.listen((newDuration) { - setState(() { - duration2 = newDuration; - }); - }); - - audio2.onAudioPositionChanged.listen((newPosition) { - setState(() { - position2 = newPosition ; - }); - }); - - /////////////// - //////////////////// audio3 - setAudio3(); - audio3.onAudioPositionChanged.listen((state) { - setState(() { - isPlaying3 = state == PlayerState.PLAYING; - }); - }); - - audio3.onDurationChanged.listen((newDuration) { - setState(() { - duration3 = newDuration; - }); - }); - - audio3.onAudioPositionChanged.listen((newPosition) { - setState(() { - position3 = newPosition ; - }); - }); } Future setAudio() async{ @@ -90,28 +50,11 @@ class _HomePageState extends State { audioPlayer.setUrl(url.path,isLocal: true); } - Future setAudio2() async{ - audio2.setReleaseMode(ReleaseMode.RELEASE); - final p2 = AudioCache(prefix: 'assets/audio/'); - final url2 = await p2.load('gameover.wav'); - - audio2.setUrl(url2.path,isLocal: true); - } - - Future setAudio3() async{ - audio3.setReleaseMode(ReleaseMode.RELEASE); - final p3 = AudioCache(prefix: 'assets/audio/'); - final url3 = await p3.load('point.mp3'); - - audio3.setUrl(url3.path,isLocal: true); - } @override void dispose(){ audioPlayer.dispose(); - audio2.dispose(); - audio3.dispose(); super.dispose(); } @@ -218,10 +161,6 @@ class _HomePageState extends State { } else { setState(() { if (SCORE == TOP_SCORE) { - if (isPlaying3 == false) - { - audio3.resume(); - } TOP_SCORE++; // TODO: add the Top score to Database write(1, TOP_SCORE); @@ -237,11 +176,6 @@ class _HomePageState extends State { bool birdIsDead() { // Screen if (yAxis > 1.26 || yAxis < -1.1) { - /// Game Over Audio Plays in case bird dies - if (isPlaying2 == false) - { - audio2.resume(); - } return true; } @@ -251,10 +185,7 @@ class _HomePageState extends State { (barrierX[i] + (barrierWidth)) >= birdWidth && (yAxis <= -1 + barrierHeight[i][0] || yAxis + birdHeight >= 1 - barrierHeight[i][1])) { - if (isPlaying2== false) - { - audio2.resume(); - } + return true; } }