Skip to content

Commit 22516b8

Browse files
authored
Merge pull request #13 from SalmaBasem20191743/main
Audio Edit
2 parents 415d823 + c1e870c commit 22516b8

File tree

6 files changed

+1
-84
lines changed

6 files changed

+1
-84
lines changed

assets/audio/Bones.mp3

-2.52 MB
Binary file not shown.

assets/audio/gameover.wav

-967 KB
Binary file not shown.

assets/audio/hit.mp3

-16.1 KB
Binary file not shown.

assets/audio/point.mp3

-22.7 KB
Binary file not shown.

lib/Constant/constant.dart

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,6 @@ Duration duration = Duration.zero;
5151
Duration position = Duration.zero;
5252

5353

54-
/////////////////// GameOver audio
55-
final audio2 = AudioPlayer();
56-
bool isPlaying2 = false;
57-
Duration duration2 = Duration.zero;
58-
Duration position2 = Duration.zero;
59-
60-
61-
62-
//////////////////// Point audio
63-
final audio3 = AudioPlayer();
64-
bool isPlaying3 = false;
65-
Duration duration3 = Duration.zero;
66-
Duration position3 = Duration.zero;
67-
6854
/// to decide which page that class [Button] will navigate
6955
enum Navigation{ home, settings, leaderBord }
7056

lib/Layouts/Pages/page_home.dart

Lines changed: 1 addition & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -41,46 +41,6 @@ class _HomePageState extends State<HomePage> {
4141
});
4242
});
4343

44-
//////////////////// audio2
45-
setAudio2();
46-
audio2.onAudioPositionChanged.listen((state) {
47-
setState(() {
48-
isPlaying2 = state == PlayerState.PLAYING;
49-
});
50-
});
51-
52-
audio2.onDurationChanged.listen((newDuration) {
53-
setState(() {
54-
duration2 = newDuration;
55-
});
56-
});
57-
58-
audio2.onAudioPositionChanged.listen((newPosition) {
59-
setState(() {
60-
position2 = newPosition ;
61-
});
62-
});
63-
64-
///////////////
65-
//////////////////// audio3
66-
setAudio3();
67-
audio3.onAudioPositionChanged.listen((state) {
68-
setState(() {
69-
isPlaying3 = state == PlayerState.PLAYING;
70-
});
71-
});
72-
73-
audio3.onDurationChanged.listen((newDuration) {
74-
setState(() {
75-
duration3 = newDuration;
76-
});
77-
});
78-
79-
audio3.onAudioPositionChanged.listen((newPosition) {
80-
setState(() {
81-
position3 = newPosition ;
82-
});
83-
});
8444
}
8545

8646
Future setAudio() async{
@@ -90,28 +50,11 @@ class _HomePageState extends State<HomePage> {
9050

9151
audioPlayer.setUrl(url.path,isLocal: true);
9252
}
93-
Future setAudio2() async{
94-
audio2.setReleaseMode(ReleaseMode.RELEASE);
95-
final p2 = AudioCache(prefix: 'assets/audio/');
96-
final url2 = await p2.load('gameover.wav');
97-
98-
audio2.setUrl(url2.path,isLocal: true);
99-
}
100-
101-
Future setAudio3() async{
102-
audio3.setReleaseMode(ReleaseMode.RELEASE);
103-
final p3 = AudioCache(prefix: 'assets/audio/');
104-
final url3 = await p3.load('point.mp3');
105-
106-
audio3.setUrl(url3.path,isLocal: true);
107-
}
10853

10954
@override
11055

11156
void dispose(){
11257
audioPlayer.dispose();
113-
audio2.dispose();
114-
audio3.dispose();
11558
super.dispose();
11659
}
11760

@@ -218,10 +161,6 @@ class _HomePageState extends State<HomePage> {
218161
} else {
219162
setState(() {
220163
if (SCORE == TOP_SCORE) {
221-
if (isPlaying3 == false)
222-
{
223-
audio3.resume();
224-
}
225164
TOP_SCORE++;
226165
// TODO: add the Top score to Database
227166
write(1, TOP_SCORE);
@@ -237,11 +176,6 @@ class _HomePageState extends State<HomePage> {
237176
bool birdIsDead() {
238177
// Screen
239178
if (yAxis > 1.26 || yAxis < -1.1) {
240-
/// Game Over Audio Plays in case bird dies
241-
if (isPlaying2 == false)
242-
{
243-
audio2.resume();
244-
}
245179
return true;
246180
}
247181

@@ -251,10 +185,7 @@ class _HomePageState extends State<HomePage> {
251185
(barrierX[i] + (barrierWidth)) >= birdWidth &&
252186
(yAxis <= -1 + barrierHeight[i][0] ||
253187
yAxis + birdHeight >= 1 - barrierHeight[i][1])) {
254-
if (isPlaying2== false)
255-
{
256-
audio2.resume();
257-
}
188+
258189
return true;
259190
}
260191
}

0 commit comments

Comments
 (0)