Skip to content

Commit

Permalink
flutter 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
PScottZero committed Jun 10, 2021
1 parent 7f456cd commit 851840c
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 51 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.5.10'
repositories {
google()
jcenter()
Expand Down
14 changes: 7 additions & 7 deletions lib/logic/chess_game.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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();
}
}

Expand Down
10 changes: 2 additions & 8 deletions lib/logic/chess_piece_sprite.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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) {
Expand Down Expand Up @@ -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');
}
}
}
Expand Down
1 change: 0 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 0 additions & 5 deletions lib/views/main_menu_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -17,10 +16,6 @@ class _MainMenuViewState extends State<MainMenuView> {
Widget build(BuildContext context) {
return Consumer<AppModel>(
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),
Expand Down
85 changes: 60 additions & 25 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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"
8 changes: 4 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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.
Expand Down Expand Up @@ -102,4 +102,4 @@ flutter:
- assets/images/pieces/videochess/
- assets/images/pieces/lewischessmen/
- assets/images/pieces/mexicocity/
- assets/audio/
- assets/audio/piece_moved.ogg

0 comments on commit 851840c

Please sign in to comment.