Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
feat: add wrong bin sound effect
Browse files Browse the repository at this point in the history
  • Loading branch information
alestiago committed Mar 10, 2024
1 parent 466f0ef commit febf6ea
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
Binary file added packages/trashy_road/assets/audio/wrong_bin.mp3
Binary file not shown.
6 changes: 5 additions & 1 deletion packages/trashy_road/lib/gen/assets.gen.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion packages/trashy_road/lib/src/audio/bloc/audio_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,26 @@ class GameAudioData {
const GameAudioData._({
required AssetSource source,
required double volume,
Duration? duration,
}) : _source = source,
_volume = volume;
_volume = volume,
_duration = duration;

GameAudioData.fromPath(
String path, {
required double volume,
Duration? duration,
}) : this._(
source: AssetSource(path),
volume: volume,
duration: duration,
);

final AssetSource _source;

final double _volume;

final Duration? _duration;
}

abstract class GameBackgroundMusic {
Expand Down Expand Up @@ -89,4 +95,10 @@ abstract class GameSoundEffects {
Assets.audio.ratingStars3,
volume: 0.25,
);

static final wrongBin = GameAudioData.fromPath(
Assets.audio.wrongBin,
volume: 0.25,
duration: const Duration(seconds: 1),
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ class TrashCanDepositingBehavior extends Behavior<TrashCan>
///
/// Does nothing if the [TrashCan] cannot deposit some trash.
void deposit() {
if (!_canDeposit()) return;
if (!_canDeposit()) {
game.audioBloc.playEffect(GameSoundEffects.wrongBin);
return;
}

game.audioBloc.playEffect(
_depositSoundEffects.elementAt(
Expand Down

0 comments on commit febf6ea

Please sign in to comment.