From 9437bf3af43b98944d42c12160c6848debc6ecda Mon Sep 17 00:00:00 2001 From: khalidishani Date: Mon, 24 May 2021 12:40:40 -0700 Subject: [PATCH] added sound effects --- assets/audio/buzz.mp3 | Bin 8420 -> 6330 bytes lib/Maze.dart | 4 ++ lib/MazeTest.dart | 2 + lib/main.dart | 9 ++++ pubspec.lock | 109 ++++++++++++++++++++++++++++++++---------- pubspec.yaml | 6 +++ 6 files changed, 106 insertions(+), 24 deletions(-) diff --git a/assets/audio/buzz.mp3 b/assets/audio/buzz.mp3 index dabaaa2beeb28531cf574007f5aa0f20439dd736..c24107fe9f848073283505aaecc85d2352fa783d 100644 GIT binary patch delta 120 zcmaFjxXW-tZYV1QgG3EOC?;sY0#;!GSFwP}fvh4EuPL!f)PyXa61$m^F_4*=fq`Lj II!A^G08%nJ=>Px# delta 2057 zcmc)Jdoi{7m>^jIK$QW% zZ)o3!m>asZv9=9OZRmVAK?YT(w1cbH0D+LDKmY(FtD-MgzR=ZuC=MkvQYpW;<~cAK z7U6QIl_}L{H2cxI7C@;}aB7jMS2RS7GCHD*8hW7IxJN$R?xGf;5D8P%+J87(ncqD| zgJ3YxU$%sXcS5Lb$RXCg%jS8(|KfA5SXiA$YD3y4`eM6g+#e&BU4Ku?|E8-j<*sM zW&uq==3#lb(e`DFS}jb6h-Ha| z=VTVidAj7Wr?;H1IbD0;VJXtN0K>5G;CjwdWk1h^u$k=k;`AbyWA&`ih&hm+w#tc> z3eBwUcmmPztq4?&o?7l8G6@3}WTHqLiuk2xe}c8i5u`gWYMzq+!0@PH$}N-Ky-WOp z*QNSKlf$>i7n)L%gJZ?XCz3;&c@~D}R!<&!bho^n>wvbndbmGa_)08s+ge{_*4b&! z6ONq;@e*|g_(73o_VE|{$3Qfw6i@3`3eni34L{PCqBJJd#Q&ueeb%z@0u<`1xnH#p z*Pwoo!fx-<^PfXlF-TXvrQyLdql53;n@+nQ;p0|$AEcVMQ(<}LThz3@YHo9o`F(zZ@tI`sc)hjh%Tz?@mBP+Q3cT55ai6zxLkq4h0n3W z^MR%AHgS5_y0$ME$Yw%Ni9;>TjDf@(fhdt@7s>3nwR?V)M(* zcm848HYe!f+HpDjh&G8UPV%KZ3XBSh(Fzq+z5&F`OFB>O9N%*sjL2oFj z6Vi;@GPHf@B7wah3@wE;v_cN6_A2Gwj0mupvnJz8cHP<@x2r42q2IL;(EJ>y`%cbj zEo`m8B@nv83PbQly9mr`)#mc(!R7EZ0sp;j@-00G9h)^yXE?Byce9$sTYgvHqb zWa%B->d}^}3u4C?*eLUq>stB&_^iN@&ZsSQGC?W=?s%x!ZtC9w|F1Pp(kfZIBMJLX R^;b0bQ`BG4q#vNB{R7MP!QlV^ diff --git a/lib/Maze.dart b/lib/Maze.dart index b0bf4e1..dd333a2 100644 --- a/lib/Maze.dart +++ b/lib/Maze.dart @@ -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(); @@ -140,6 +142,7 @@ class gameButtonState extends State { 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) { @@ -202,6 +205,7 @@ class gameButtonState extends State { //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; diff --git a/lib/MazeTest.dart b/lib/MazeTest.dart index f337422..a16a15e 100644 --- a/lib/MazeTest.dart +++ b/lib/MazeTest.dart @@ -173,6 +173,7 @@ class gameButtonState extends State { 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; @@ -239,6 +240,7 @@ class gameButtonState extends State { //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; diff --git a/lib/main.dart b/lib/main.dart index e9741a9..b42449e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -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(); @@ -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++) { @@ -44,6 +50,9 @@ void main() { } + + + return runApp(MaterialApp( home: Scaffold( appBar: AppBar( diff --git a/pubspec.lock b/pubspec.lock index 2900035..85be819 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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" diff --git a/pubspec.yaml b/pubspec.yaml index 197fc8d..74a6397 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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: @@ -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.