Skip to content

Commit

Permalink
Merge pull request #13 from SalmaBasem20191743/main
Browse files Browse the repository at this point in the history
Audio Edit
  • Loading branch information
moha-b authored Sep 1, 2022
2 parents 415d823 + c1e870c commit 22516b8
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 84 deletions.
Binary file removed assets/audio/Bones.mp3
Binary file not shown.
Binary file removed assets/audio/gameover.wav
Binary file not shown.
Binary file removed assets/audio/hit.mp3
Binary file not shown.
Binary file removed assets/audio/point.mp3
Binary file not shown.
14 changes: 0 additions & 14 deletions lib/Constant/constant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
71 changes: 1 addition & 70 deletions lib/Layouts/Pages/page_home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,46 +41,6 @@ class _HomePageState extends State<HomePage> {
});
});

//////////////////// 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{
Expand All @@ -90,28 +50,11 @@ class _HomePageState extends State<HomePage> {

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();
}

Expand Down Expand Up @@ -218,10 +161,6 @@ class _HomePageState extends State<HomePage> {
} else {
setState(() {
if (SCORE == TOP_SCORE) {
if (isPlaying3 == false)
{
audio3.resume();
}
TOP_SCORE++;
// TODO: add the Top score to Database
write(1, TOP_SCORE);
Expand All @@ -237,11 +176,6 @@ class _HomePageState extends State<HomePage> {
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;
}

Expand All @@ -251,10 +185,7 @@ class _HomePageState extends State<HomePage> {
(barrierX[i] + (barrierWidth)) >= birdWidth &&
(yAxis <= -1 + barrierHeight[i][0] ||
yAxis + birdHeight >= 1 - barrierHeight[i][1])) {
if (isPlaying2== false)
{
audio2.resume();
}

return true;
}
}
Expand Down

0 comments on commit 22516b8

Please sign in to comment.