Skip to content

Commit

Permalink
v1.7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
PScottZero committed Jun 13, 2021
1 parent 8e2d639 commit 8be5b93
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 22 deletions.
8 changes: 6 additions & 2 deletions lib/logic/chess_piece_sprite.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
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 @@ -18,6 +18,9 @@ class ChessPieceSprite {
double offsetX = 0;
double offsetY = 0;

AudioCache audioCache = AudioCache();
AudioPlayer audioPlayer = AudioPlayer();

ChessPieceSprite(ChessPiece piece, String pieceTheme) {
this.tile = piece.tile;
this.type = piece.type;
Expand Down Expand Up @@ -62,7 +65,8 @@ 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) {
FlameAudio.play('piece_moved.mp3');
final bytes = await (await audioCache.loadAsFile('audio/piece_moved.mp3')).readAsBytes();
audioPlayer.playBytes(bytes);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void main() {
_loadFlameAssets();
}

void _loadFlameAssets() {
void _loadFlameAssets() async {
List<String> pieceImages = [];
for (var theme in PIECE_THEMES) {
for (var color in ['black', 'white']) {
Expand All @@ -28,7 +28,7 @@ void _loadFlameAssets() {
}
}
}
Flame.images.loadAll(pieceImages);
await Flame.images.loadAll(pieceImages);
}

class EnPassantApp extends StatelessWidget {
Expand Down
16 changes: 16 additions & 0 deletions lib/model/app_themes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,22 @@ List<AppTheme> get themeList {
latestMove: Color(0xaa2782b0),
border: Color(0xffebc0c0),
),
AppTheme(
name: 'Cherry-Coloured Funk',
background: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Color(0xff434783),
Color(0xffdc3b39),
],
),
lightTile: Color(0xffdb5e5c),
darkTile: Color(0xff645183),
moveHint: Color(0xaabdacce),
latestMove: Color(0xaaf0b35d),
border: Color(0xff434783),
),
];
themeList.sort((a, b) => a.name.compareTo(b.name));
return themeList;
Expand Down
20 changes: 3 additions & 17 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ packages:
source: hosted
version: "2.6.1"
audioplayers:
dependency: transitive
dependency: "direct main"
description:
name: audioplayers
url: "https://pub.dartlang.org"
Expand Down Expand Up @@ -106,13 +106,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
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 Down Expand Up @@ -350,13 +343,6 @@ 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 Down Expand Up @@ -440,7 +426,7 @@ packages:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.5"
version: "2.0.5"
xdg_directories:
dependency: transitive
description:
Expand All @@ -463,5 +449,5 @@ packages:
source: hosted
version: "3.1.0"
sdks:
dart: ">=2.13.0 <3.0.0"
dart: ">=2.12.0 <3.0.0"
flutter: ">=2.0.0"
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ dependencies:
sdk: flutter
provider: ^5.0.0
flame: ^1.0.0-releasecandidate.11
flame_audio: ^1.0.0-rc.1
url_launcher: ^6.0.2
audioplayers: ^0.19.0
shared_preferences:
async:

Expand Down

0 comments on commit 8be5b93

Please sign in to comment.