Skip to content

Commit

Permalink
added sound effects
Browse files Browse the repository at this point in the history
  • Loading branch information
KhalidIshani committed May 24, 2021
1 parent 4023566 commit 9437bf3
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 24 deletions.
Binary file modified assets/audio/buzz.mp3
Binary file not shown.
4 changes: 4 additions & 0 deletions lib/Maze.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import 'main.dart';
import 'instructions.dart';
import 'package:uuid/uuid.dart';
import 'userIDD.dart';
import 'package:audioplayers/audio_cache.dart';
import 'package:audioplayers/audioplayers.dart';

var uuid = Uuid();
DateTime startTime = DateTime.now();
Expand Down Expand Up @@ -140,6 +142,7 @@ class gameButtonState extends State<gameButton> {
errors.add("correct");
maze1.button_grid[widget.id].color = Colors.green;
maze1.button_grid[widget.id].displayImage = true;
audioCache.play('ding2.mp3');
icon = Icons.check;
Timer(Duration(milliseconds: 75), () {
if (this.mounted) {
Expand Down Expand Up @@ -202,6 +205,7 @@ class gameButtonState extends State<gameButton> {
//keep track of how many consecutive errors user has made- if 3 then game should show next correct move
consecErrors++;
errors.add("incorrect");
audioCache.play('buzz2.mp3');
maze1.button_grid[widget.id].color = Colors.red;
maze1.button_grid[widget.id].displayImage=true;
icon = Icons.clear;
Expand Down
2 changes: 2 additions & 0 deletions lib/MazeTest.dart
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ class gameButtonState extends State<gameButton> {
if(widget.moveCheck()) {
consecErrors2 = 0;
maze2.button_grid[widget.id].color = Colors.green;
audioCache.play('ding2.mp3');
errors2.add("correct");
maze2.button_grid[widget.id].displayImage = true;
icon = Icons.check;
Expand Down Expand Up @@ -239,6 +240,7 @@ class gameButtonState extends State<gameButton> {
//keep track of how many consecutive errors user has made- if 3 then game should show next correct move
consecErrors2++;
maze2.button_grid[widget.id].color = Colors.red;
audioCache.play('buzz2.mp3');
errors2.add("incorrect");
maze2.button_grid[widget.id].displayImage=true;
icon = Icons.clear;
Expand Down
9 changes: 9 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import 'server.dart';
import 'startingScreen.dart';
import 'Maze.dart';
import 'userIDD.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:audioplayers/audio_cache.dart';
import 'package:audioplayers/audioplayers.dart';

//initialize new maze
maze maze1= new maze();
Expand All @@ -31,8 +34,11 @@ var dateTime = DateTime.now();
int attemptNum = 1;
int consecErrors = 0;
int recentMove; //records last move of user regardless of corectness
final AudioCache audioCache = AudioCache(prefix: "audio/", fixedPlayer: AudioPlayer()..setReleaseMode(ReleaseMode.STOP));

void main() {


//manually fill in maze
/*for(var i=0; i<19; i++)
{
Expand All @@ -44,6 +50,9 @@ void main() {
}





return runApp(MaterialApp(
home: Scaffold(
appBar: AppBar(
Expand Down
109 changes: 85 additions & 24 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,49 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0-nullsafety.1"
version: "2.5.0"
audioplayers:
dependency: "direct main"
description:
name: audioplayers
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.7"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.1"
version: "2.1.0"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.3"
version: "1.1.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
version: "1.2.0"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.1"
version: "1.1.0"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0-nullsafety.3"
version: "1.15.0"
convert:
dependency: transitive
description:
Expand All @@ -64,20 +71,62 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
device_info_plus:
dependency: "direct main"
description:
name: device_info_plus
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0-nullsafety.1"
device_info_plus_linux:
dependency: transitive
description:
name: device_info_plus_linux
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0-nullsafety.0"
device_info_plus_macos:
dependency: transitive
description:
name: device_info_plus_macos
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0-nullsafety.0"
device_info_plus_platform_interface:
dependency: transitive
description:
name: device_info_plus_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0-nullsafety.0"
device_info_plus_web:
dependency: transitive
description:
name: device_info_plus_web
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0-nullsafety.0"
device_info_plus_windows:
dependency: transitive
description:
name: device_info_plus_windows
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0-nullsafety.0"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
version: "1.2.0"
ffi:
dependency: transitive
description:
name: ffi
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
version: "1.0.0"
file:
dependency: transitive
description:
Expand All @@ -95,6 +144,11 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
http:
dependency: "direct main"
description:
Expand All @@ -116,6 +170,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.16.1"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3"
json_annotation:
dependency: "direct main"
description:
Expand All @@ -129,21 +190,21 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.10-nullsafety.1"
version: "0.12.10"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.3"
version: "1.3.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.1"
version: "1.8.0"
path_provider:
dependency: "direct main"
description:
Expand Down Expand Up @@ -178,7 +239,7 @@ packages:
name: path_provider_windows
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.4+3"
version: "0.0.5"
pedantic:
dependency: transitive
description:
Expand Down Expand Up @@ -213,7 +274,7 @@ packages:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
version: "1.1.0-nullsafety.2"
process:
dependency: transitive
description:
Expand All @@ -239,49 +300,49 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.2"
version: "1.8.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0-nullsafety.1"
version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.1"
version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.1"
version: "1.1.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
version: "1.2.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19-nullsafety.2"
version: "0.2.19"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.3"
version: "1.3.0"
uuid:
dependency: "direct main"
description:
Expand All @@ -295,14 +356,14 @@ packages:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.3"
version: "2.1.0"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.4+1"
version: "2.0.5"
xdg_directories:
dependency: transitive
description:
Expand All @@ -311,5 +372,5 @@ packages:
source: hosted
version: "0.1.2"
sdks:
dart: ">=2.10.0-110 <2.11.0"
flutter: ">=1.12.13+hotfix.5 <2.0.0"
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.20.0"
6 changes: 6 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3
device_info_plus: ^1.0.0-nullsafety.0
audioplayers: ^0.13.2


dev_dependencies:
flutter_test:
Expand All @@ -56,6 +59,9 @@ flutter:
- assets/mazeimage2.PNG
- assets/aSpades.PNG
- assets/cardBack.PNG
- assets/audio/ding2.mp3
- assets/audio/buzz.mp3
- assets/audio/buzz2.mp3

# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
Expand Down

0 comments on commit 9437bf3

Please sign in to comment.