diff --git a/android/build.gradle b/android/build.gradle index c505a86..b3afb28 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlin_version = '1.3.50' + ext.kotlin_version = '1.5.10' repositories { google() jcenter() diff --git a/lib/logic/chess_game.dart b/lib/logic/chess_game.dart index 92f5734..118c756 100644 --- a/lib/logic/chess_game.dart +++ b/lib/logic/chess_game.dart @@ -44,9 +44,9 @@ class ChessGame extends Game with TapDetector { } @override - void onTapDown(TapDownDetails details) { + void onTapDown(TapDownInfo details) { if (appModel.gameOver || !(appModel.isAIsTurn)) { - var tile = _offsetToTile(details.localPosition); + var tile = _vector2ToTile(details.eventPosition.widget); var touchedPiece = board.tiles[tile]; if (touchedPiece == selectedPiece) { validMoves = []; @@ -248,15 +248,15 @@ class ChessGame extends Game with TapDetector { } } - int _offsetToTile(Offset offset) { + int _vector2ToTile(Vector2 vector2) { if (appModel.flip && appModel.playingWithAI && appModel.playerSide == Player.player2) { - return (7 - (offset.dy / tileSize).floor()) * 8 + - (7 - (offset.dx / tileSize).floor()); + return (7 - (vector2.y / tileSize).floor()) * 8 + + (7 - (vector2.x / tileSize).floor()); } else { - return (offset.dy / tileSize).floor() * 8 + - (offset.dx / tileSize).floor(); + return (vector2.y / tileSize).floor() * 8 + + (vector2.x / tileSize).floor(); } } diff --git a/lib/logic/chess_piece_sprite.dart b/lib/logic/chess_piece_sprite.dart index c06966c..3f9ad86 100644 --- a/lib/logic/chess_piece_sprite.dart +++ b/lib/logic/chess_piece_sprite.dart @@ -1,10 +1,10 @@ -import 'package:audioplayers/audio_cache.dart'; import 'package:audioplayers/audioplayers.dart'; import 'package:en_passant/model/app_model.dart'; import 'package:en_passant/views/components/main_menu_view/game_options/side_picker.dart'; import 'package:flame/components.dart'; import 'package:flame/flame.dart'; import 'package:flame/sprite.dart'; +import 'package:flame_audio/flame_audio.dart'; import 'chess_piece.dart'; import 'shared_functions.dart'; @@ -28,12 +28,6 @@ class ChessPieceSprite { this.type = piece.type; this.pieceTheme = pieceTheme; initSprite(piece); - loadAudio(); - } - - void loadAudio() async { - pieceMovedSound = - await (await audioCache.load('audio/piece_moved.ogg')).readAsBytes(); } void update(double tileSize, AppModel appModel, ChessPiece piece) { @@ -73,7 +67,7 @@ class ChessPieceSprite { void playSound(double destX, double destY, AppModel appModel) async { if ((destX - spriteX).abs() <= 0.1 && (destY - spriteY).abs() <= 0.1) { if (appModel.soundEnabled) { - await audioPlayer.playBytes(pieceMovedSound); + FlameAudio.play('piece_moved.ogg'); } } } diff --git a/lib/main.dart b/lib/main.dart index a7b4990..510cf20 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -37,7 +37,6 @@ class EnPassantApp extends StatelessWidget { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); return CupertinoApp( title: 'En Passant', - debugShowCheckedModeBanner: false, theme: CupertinoThemeData( brightness: Brightness.dark, textTheme: CupertinoTextThemeData( diff --git a/lib/views/main_menu_view.dart b/lib/views/main_menu_view.dart index 53c6751..5aee05c 100644 --- a/lib/views/main_menu_view.dart +++ b/lib/views/main_menu_view.dart @@ -2,7 +2,6 @@ import 'package:en_passant/model/app_model.dart'; import 'package:en_passant/views/components/main_menu_view/game_options.dart'; import 'package:en_passant/views/components/shared/bottom_padding.dart'; import 'package:flutter/cupertino.dart'; -import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; import 'components/main_menu_view/main_menu_buttons.dart'; @@ -17,10 +16,6 @@ class _MainMenuViewState extends State { Widget build(BuildContext context) { return Consumer( builder: (context, appModel, child) { - SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( - statusBarColor: appModel.theme.background.colors.first, - systemNavigationBarColor: appModel.theme.background.colors.last, - )); return Container( decoration: BoxDecoration(gradient: appModel.theme.background), padding: EdgeInsets.all(30), diff --git a/pubspec.lock b/pubspec.lock index f41f3c9..45f67cd 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -21,14 +21,14 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.6.1" audioplayers: - dependency: "direct main" + dependency: transitive description: name: audioplayers url: "https://pub.dartlang.org" source: hosted - version: "0.18.3" + version: "0.19.0" boolean_selector: dependency: transitive description: @@ -70,14 +70,14 @@ packages: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.1" cupertino_icons: dependency: "direct main" description: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "1.0.3" fake_async: dependency: transitive description: @@ -91,21 +91,28 @@ packages: name: ffi url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.1.2" file: dependency: transitive description: name: file url: "https://pub.dartlang.org" source: hosted - version: "6.1.0" + version: "6.1.1" flame: dependency: "direct main" description: name: flame url: "https://pub.dartlang.org" source: hosted - version: "1.0.0-rc8" + version: "1.0.0-releasecandidate.11" + flame_audio: + dependency: "direct main" + description: + name: flame_audio + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0-rc.1" flutter: dependency: "direct main" description: flutter @@ -128,13 +135,27 @@ packages: description: flutter source: sdk version: "0.0.0" + http: + dependency: transitive + description: + name: http + url: "https://pub.dartlang.org" + source: hosted + version: "0.13.3" + http_parser: + dependency: transitive + description: + name: http_parser + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.0" image: dependency: transitive description: name: image url: "https://pub.dartlang.org" source: hosted - version: "3.0.1" + version: "3.0.2" js: dependency: transitive description: @@ -169,7 +190,7 @@ packages: name: ordered_set url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.1.0" path: dependency: transitive description: @@ -183,7 +204,7 @@ packages: name: path_provider url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.2" path_provider_linux: dependency: transitive description: @@ -211,14 +232,21 @@ packages: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.1" + pedantic: + dependency: transitive + description: + name: pedantic + url: "https://pub.dartlang.org" + source: hosted + version: "1.11.0" petitparser: dependency: transitive description: name: petitparser url: "https://pub.dartlang.org" source: hosted - version: "4.0.2" + version: "4.1.0" platform: dependency: transitive description: @@ -239,7 +267,7 @@ packages: name: process url: "https://pub.dartlang.org" source: hosted - version: "4.1.0" + version: "4.2.1" provider: dependency: "direct main" description: @@ -253,7 +281,7 @@ packages: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.6" shared_preferences_linux: dependency: transitive description: @@ -300,7 +328,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" stack_trace: dependency: transitive description: @@ -322,6 +350,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.0" + synchronized: + dependency: transitive + description: + name: synchronized + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" term_glyph: dependency: transitive description: @@ -335,7 +370,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" + version: "0.3.0" typed_data: dependency: transitive description: @@ -349,7 +384,7 @@ packages: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "6.0.2" + version: "6.0.6" url_launcher_linux: dependency: transitive description: @@ -370,14 +405,14 @@ packages: name: url_launcher_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.0.3" url_launcher_web: dependency: transitive description: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.1" url_launcher_windows: dependency: transitive description: @@ -391,7 +426,7 @@ packages: name: uuid url: "https://pub.dartlang.org" source: hosted - version: "3.0.3" + version: "3.0.4" vector_math: dependency: transitive description: @@ -405,7 +440,7 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.5" xdg_directories: dependency: transitive description: @@ -419,7 +454,7 @@ packages: name: xml url: "https://pub.dartlang.org" source: hosted - version: "5.0.2" + version: "5.1.2" yaml: dependency: transitive description: @@ -428,5 +463,5 @@ packages: source: hosted version: "3.1.0" sdks: - dart: ">=2.12.0 <3.0.0" - flutter: ">=1.24.0-10.2.pre" + dart: ">=2.13.0 <3.0.0" + flutter: ">=2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 2b103e6..e259583 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.7.3+17 +version: 1.7.4+18 environment: sdk: ">=2.7.0 <3.0.0" @@ -24,11 +24,11 @@ dependencies: flutter: sdk: flutter provider: ^5.0.0 - flame: ^1.0.0-rc8 + flame: ^1.0.0-releasecandidate.11 + flame_audio: ^1.0.0-rc.1 url_launcher: ^6.0.2 shared_preferences: async: - audioplayers: ^0.18.3 # The following adds the Cupertino Icons font to your application. @@ -102,4 +102,4 @@ flutter: - assets/images/pieces/videochess/ - assets/images/pieces/lewischessmen/ - assets/images/pieces/mexicocity/ - - assets/audio/ + - assets/audio/piece_moved.ogg