Skip to content

Commit

Permalink
broke image assets when trying to use images from asset and not network
Browse files Browse the repository at this point in the history
  • Loading branch information
mahdafr committed Jul 9, 2023
1 parent ad45459 commit 8047e56
Show file tree
Hide file tree
Showing 99 changed files with 157 additions and 345 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,6 @@ app/.flutter-plugins
app/.flutter-plugins-dependencies
.vscode/
*.lock

app/build
app/assets/images/dogs/*.jpg
Binary file removed app/assets/music/Mr_Smith-Azul.mp3
Binary file not shown.
Binary file removed app/assets/music/Mr_Smith-Sonorus.mp3
Binary file not shown.
Binary file removed app/assets/music/Mr_Smith-Sunday_Solitude.mp3
Binary file not shown.
7 changes: 1 addition & 6 deletions app/assets/music/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
Music in the template is by Mr Smith, and licensed under Creative Commons
Attribution 4.0 International (CC BY 4.0).

https://freemusicarchive.org/music/mr-smith

Mr Smith's music is used in this template project with his explicit permission.
Music was sourced from sites such as [pixabay.com](https://pixabay.com/music/search/genre/video%20games/) and [tunetank.com](https://tunetank.com/gaming/)
Binary file added app/assets/music/background0.mp3
Binary file not shown.
Binary file added app/assets/music/background1.mp3
Binary file not shown.
Binary file added app/assets/music/background2.mp3
Binary file not shown.
1 change: 0 additions & 1 deletion app/assets/sfx/README.md

This file was deleted.

Binary file added app/assets/sfx/chih.wav
Binary file not shown.
Binary file removed app/assets/sfx/dsht1.mp3
Binary file not shown.
Binary file removed app/assets/sfx/ehehee1.mp3
Binary file not shown.
Binary file removed app/assets/sfx/fwfwfwfw1.mp3
Binary file not shown.
Binary file removed app/assets/sfx/fwfwfwfwfw1.mp3
Binary file not shown.
Binary file removed app/assets/sfx/hash1.mp3
Binary file not shown.
Binary file removed app/assets/sfx/hash2.mp3
Binary file not shown.
Binary file removed app/assets/sfx/hash3.mp3
Binary file not shown.
Binary file removed app/assets/sfx/haw1.mp3
Binary file not shown.
Binary file removed app/assets/sfx/hh1.mp3
Binary file not shown.
Binary file removed app/assets/sfx/hh2.mp3
Binary file not shown.
Binary file added app/assets/sfx/husk.wav
Binary file not shown.
Binary file removed app/assets/sfx/k1.mp3
Binary file not shown.
Binary file removed app/assets/sfx/k2.mp3
Binary file not shown.
Binary file removed app/assets/sfx/kch1.mp3
Binary file not shown.
Binary file removed app/assets/sfx/kss1.mp3
Binary file not shown.
Binary file removed app/assets/sfx/lalala1.mp3
Binary file not shown.
Binary file removed app/assets/sfx/oo1.mp3
Binary file not shown.
Binary file removed app/assets/sfx/p1.mp3
Binary file not shown.
Binary file removed app/assets/sfx/p2.mp3
Binary file not shown.
Binary file added app/assets/sfx/pug.wav
Binary file not shown.
Binary file removed app/assets/sfx/sh1.mp3
Binary file not shown.
Binary file removed app/assets/sfx/sh2.mp3
Binary file not shown.
Binary file removed app/assets/sfx/spsh1.mp3
Binary file not shown.
Binary file removed app/assets/sfx/swishswish1.mp3
Binary file not shown.
Binary file removed app/assets/sfx/wehee1.mp3
Binary file not shown.
Binary file removed app/assets/sfx/ws1.mp3
Binary file not shown.
Binary file removed app/assets/sfx/wssh1.mp3
Binary file not shown.
Binary file removed app/assets/sfx/wssh2.mp3
Binary file not shown.
Binary file removed app/assets/sfx/yay1.mp3
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion app/build/flutter_assets/AssetManifest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"assets/Permanent_Marker/PermanentMarker-Regular.ttf":["assets/Permanent_Marker/PermanentMarker-Regular.ttf"],"assets/images/back.png":["assets/images/back.png","assets/images/2x/back.png","assets/images/3.5x/back.png","assets/images/3x/back.png"],"assets/images/restart.png":["assets/images/restart.png","assets/images/2x/restart.png","assets/images/3.5x/restart.png","assets/images/3x/restart.png"],"assets/images/settings.png":["assets/images/settings.png","assets/images/2x/settings.png","assets/images/3.5x/settings.png","assets/images/3x/settings.png"],"assets/music/Mr_Smith-Azul.mp3":["assets/music/Mr_Smith-Azul.mp3"],"assets/music/Mr_Smith-Sonorus.mp3":["assets/music/Mr_Smith-Sonorus.mp3"],"assets/music/Mr_Smith-Sunday_Solitude.mp3":["assets/music/Mr_Smith-Sunday_Solitude.mp3"],"assets/music/README.md":["assets/music/README.md"],"assets/sfx/README.md":["assets/sfx/README.md"],"assets/sfx/dsht1.mp3":["assets/sfx/dsht1.mp3"],"assets/sfx/ehehee1.mp3":["assets/sfx/ehehee1.mp3"],"assets/sfx/fwfwfwfw1.mp3":["assets/sfx/fwfwfwfw1.mp3"],"assets/sfx/fwfwfwfwfw1.mp3":["assets/sfx/fwfwfwfwfw1.mp3"],"assets/sfx/hash1.mp3":["assets/sfx/hash1.mp3"],"assets/sfx/hash2.mp3":["assets/sfx/hash2.mp3"],"assets/sfx/hash3.mp3":["assets/sfx/hash3.mp3"],"assets/sfx/haw1.mp3":["assets/sfx/haw1.mp3"],"assets/sfx/hh1.mp3":["assets/sfx/hh1.mp3"],"assets/sfx/hh2.mp3":["assets/sfx/hh2.mp3"],"assets/sfx/k1.mp3":["assets/sfx/k1.mp3"],"assets/sfx/k2.mp3":["assets/sfx/k2.mp3"],"assets/sfx/kch1.mp3":["assets/sfx/kch1.mp3"],"assets/sfx/kss1.mp3":["assets/sfx/kss1.mp3"],"assets/sfx/lalala1.mp3":["assets/sfx/lalala1.mp3"],"assets/sfx/oo1.mp3":["assets/sfx/oo1.mp3"],"assets/sfx/p1.mp3":["assets/sfx/p1.mp3"],"assets/sfx/p2.mp3":["assets/sfx/p2.mp3"],"assets/sfx/sh1.mp3":["assets/sfx/sh1.mp3"],"assets/sfx/sh2.mp3":["assets/sfx/sh2.mp3"],"assets/sfx/spsh1.mp3":["assets/sfx/spsh1.mp3"],"assets/sfx/swishswish1.mp3":["assets/sfx/swishswish1.mp3"],"assets/sfx/wehee1.mp3":["assets/sfx/wehee1.mp3"],"assets/sfx/ws1.mp3":["assets/sfx/ws1.mp3"],"assets/sfx/wssh1.mp3":["assets/sfx/wssh1.mp3"],"assets/sfx/wssh2.mp3":["assets/sfx/wssh2.mp3"],"assets/sfx/yay1.mp3":["assets/sfx/yay1.mp3"],"packages/cupertino_icons/assets/CupertinoIcons.ttf":["packages/cupertino_icons/assets/CupertinoIcons.ttf"]}
{"assets/Permanent_Marker/PermanentMarker-Regular.ttf":["assets/Permanent_Marker/PermanentMarker-Regular.ttf"],"assets/images/back.png":["assets/images/back.png","assets/images/2x/back.png","assets/images/3.5x/back.png","assets/images/3x/back.png"],"assets/images/restart.png":["assets/images/restart.png","assets/images/2x/restart.png","assets/images/3.5x/restart.png","assets/images/3x/restart.png"],"assets/images/settings.png":["assets/images/settings.png","assets/images/2x/settings.png","assets/images/3.5x/settings.png","assets/images/3x/settings.png"],"assets/music/README.md":["assets/music/README.md"],"assets/music/background0.mp3":["assets/music/background0.mp3"],"assets/music/background1.mp3":["assets/music/background1.mp3"],"assets/music/background2.mp3":["assets/music/background2.mp3"],"assets/sfx/chih.wav":["assets/sfx/chih.wav"],"assets/sfx/husk.wav":["assets/sfx/husk.wav"],"assets/sfx/pug.wav":["assets/sfx/pug.wav"],"packages/cupertino_icons/assets/CupertinoIcons.ttf":["packages/cupertino_icons/assets/CupertinoIcons.ttf"]}
54 changes: 27 additions & 27 deletions app/build/flutter_assets/NOTICES
Original file line number Diff line number Diff line change
Expand Up @@ -6810,31 +6810,31 @@ limitations under the License.
--------------------------------------------------------------------------------
flutter

Copyright 2014 The Flutter Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Copyright 2014 The Flutter Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

--------------------------------------------------------------------------------
flutter_launcher_icons
Expand Down Expand Up @@ -31308,7 +31308,7 @@ xml

The MIT License

Copyright (c) 2006-2022 Lukas Renggli.
Copyright (c) 2006-2023 Lukas Renggli.
All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -34048,7 +34048,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
win32

Copyright 2019, the Dart project authors. All rights reserved.
Copyright 2019, Dart | Windows. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
7 changes: 1 addition & 6 deletions app/build/flutter_assets/assets/music/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
Music in the template is by Mr Smith, and licensed under Creative Commons
Attribution 4.0 International (CC BY 4.0).

https://freemusicarchive.org/music/mr-smith

Mr Smith's music is used in this template project with his explicit permission.
Music was sourced from sites such as [pixabay.com](https://pixabay.com/music/search/genre/video%20games/) and [tunetank.com](https://tunetank.com/gaming/)
1 change: 0 additions & 1 deletion app/build/flutter_assets/assets/sfx/README.md

This file was deleted.

Binary file removed app/build/flutter_assets/assets/sfx/dsht1.mp3
Binary file not shown.
Binary file removed app/build/flutter_assets/assets/sfx/ehehee1.mp3
Binary file not shown.
Binary file removed app/build/flutter_assets/assets/sfx/fwfwfwfw1.mp3
Binary file not shown.
Binary file removed app/build/flutter_assets/assets/sfx/fwfwfwfwfw1.mp3
Binary file not shown.
Binary file removed app/build/flutter_assets/assets/sfx/hash1.mp3
Binary file not shown.
Binary file removed app/build/flutter_assets/assets/sfx/hash2.mp3
Binary file not shown.
Binary file removed app/build/flutter_assets/assets/sfx/hash3.mp3
Binary file not shown.
Binary file removed app/build/flutter_assets/assets/sfx/haw1.mp3
Binary file not shown.
Binary file removed app/build/flutter_assets/assets/sfx/hh1.mp3
Binary file not shown.
Binary file removed app/build/flutter_assets/assets/sfx/hh2.mp3
Binary file not shown.
Binary file removed app/build/flutter_assets/assets/sfx/k1.mp3
Binary file not shown.
Binary file removed app/build/flutter_assets/assets/sfx/k2.mp3
Binary file not shown.
Binary file removed app/build/flutter_assets/assets/sfx/kch1.mp3
Binary file not shown.
Binary file removed app/build/flutter_assets/assets/sfx/kss1.mp3
Binary file not shown.
Binary file removed app/build/flutter_assets/assets/sfx/lalala1.mp3
Binary file not shown.
Binary file removed app/build/flutter_assets/assets/sfx/oo1.mp3
Binary file not shown.
Binary file removed app/build/flutter_assets/assets/sfx/p1.mp3
Binary file not shown.
Binary file removed app/build/flutter_assets/assets/sfx/p2.mp3
Binary file not shown.
Binary file removed app/build/flutter_assets/assets/sfx/sh1.mp3
Binary file not shown.
Binary file removed app/build/flutter_assets/assets/sfx/sh2.mp3
Binary file not shown.
Binary file removed app/build/flutter_assets/assets/sfx/spsh1.mp3
Binary file not shown.
Binary file not shown.
Binary file removed app/build/flutter_assets/assets/sfx/wehee1.mp3
Binary file not shown.
Binary file removed app/build/flutter_assets/assets/sfx/ws1.mp3
Binary file not shown.
Binary file removed app/build/flutter_assets/assets/sfx/wssh1.mp3
Binary file not shown.
Binary file removed app/build/flutter_assets/assets/sfx/wssh2.mp3
Binary file not shown.
Binary file removed app/build/flutter_assets/assets/sfx/yay1.mp3
Binary file not shown.
3 changes: 1 addition & 2 deletions app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ import 'package:provider/provider.dart';

import 'src/ads/ads_controller.dart';
import 'src/app_lifecycle/app_lifecycle.dart';
import 'src/audio/audio_controller.dart';
import 'src/asset_controller/audio_controller.dart';
import 'src/crashlytics/crashlytics.dart';
import 'src/dogio/character_selection.dart';
import 'src/dogio/main_menu.dart';
import 'src/dogio/play_session.dart';
import 'src/games_services/games_services.dart';
import 'src/games_services/score.dart';
import 'src/in_app_purchase/in_app_purchase.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import 'package:audioplayers/audioplayers.dart';
import 'package:flutter/widgets.dart';
import 'package:logging/logging.dart';

import '../dogio/doggo/descriptors.dart';
import '../settings/settings.dart';
import 'songs.dart';
import 'sounds.dart';


/// Allows playing music and sound. A facade to `package:audioplayers`.
class AudioController {
static final _log = Logger('AudioController');
Expand Down Expand Up @@ -108,7 +110,7 @@ class AudioController {
// This assumes there is only a limited number of sound effects in the game.
// If there are hundreds of long sound effect files, it's better
// to be more selective when preloading.
await AudioCache.instance.loadAll(SfxType.values
await AudioCache.instance.loadAll(Breed.values
.expand(soundTypeToFilename)
.map((path) => 'sfx/$path')
.toList());
Expand All @@ -119,27 +121,27 @@ class AudioController {
/// The controller will ignore this call when the attached settings'
/// [SettingsController.muted] is `true` or if its
/// [SettingsController.soundsOn] is `false`.
void playSfx(SfxType type) {
void playSfx(Breed breed) {
final muted = _settings?.muted.value ?? true;
if (muted) {
_log.info(() => 'Ignoring playing sound ($type) because audio is muted.');
_log.info(() => 'Ignoring playing sound ($breed) because audio is muted.');
return;
}
final soundsOn = _settings?.soundsOn.value ?? false;
if (!soundsOn) {
_log.info(() =>
'Ignoring playing sound ($type) because sounds are turned off.');
'Ignoring playing sound ($breed) because sounds are turned off.');
return;
}

_log.info(() => 'Playing sound: $type');
final options = soundTypeToFilename(type);
_log.info(() => 'Playing sound: $breed');
final options = soundTypeToFilename(breed);
final filename = options[_random.nextInt(options.length)];
_log.info(() => '- Chosen filename: $filename');

final currentPlayer = _sfxPlayers[_currentSfxPlayer];
currentPlayer.play(AssetSource('sfx/$filename'),
volume: soundTypeToVolume(type));
currentPlayer.play(AssetSource('dogs/$filename'),
volume: soundTypeToVolume(breed));
_currentSfxPlayer = (_currentSfxPlayer + 1) % _sfxPlayers.length;
}

Expand Down
6 changes: 6 additions & 0 deletions app/lib/src/asset_controller/images.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
final List<String> imgList = [
'assets/images/dogs/husk1.jpg',
'assets/images/dogs/chih2.jpg',
'assets/images/dogs/pug3.jpg',
];

Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@
const Set<Song> songs = {
// Filenames with whitespace break package:audioplayers on iOS
// (as of February 2022), so we use no whitespace.
Song('Mr_Smith-Azul.mp3', 'Azul', artist: 'Mr Smith'),
Song('Mr_Smith-Sonorus.mp3', 'Sonorus', artist: 'Mr Smith'),
Song('Mr_Smith-Sunday_Solitude.mp3', 'SundaySolitude', artist: 'Mr Smith'),
Song('background0.mp3', 'Azul', artist: 'UNKNOWN'),
Song('background1.mp3', 'Sonorus', artist: 'UNKNOWN'),
Song('background2.mp3', 'SundaySolitude', artist: 'UNKNOWN'),
};

class Song {
final String filename;

final String name;

final String? artist;

const Song(this.filename, this.name, {this.artist});

@override
String toString() => 'Song<$filename>';
String toString() => 'background<$filename>';
}
30 changes: 30 additions & 0 deletions app/lib/src/asset_controller/sounds.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2022, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import '../dogio/doggo/descriptors.dart';

List<String> soundTypeToFilename(Breed breed) {
switch (breed) {
case Breed.chih:
return ['chih.wav'];
case Breed.husk:
return ['husk.wav'];
case Breed.pug:
return ['pug.wav'];
default:
return ['pug.wav', 'chih.wav', 'husk.wav'];
}
}

/// Allows control over loudness of different SFX types.
double soundTypeToVolume(Breed breed) {
switch (breed) {
case Breed.chih:
return 0.4;
case Breed.pug:
return 0.2;
default:
return 1.0;
}
}

71 changes: 0 additions & 71 deletions app/lib/src/audio/sounds.dart

This file was deleted.

15 changes: 6 additions & 9 deletions app/lib/src/board/board_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:async';
import 'dart:collection' show IterableMixin;
import 'dart:math';
import 'dart:ui';

import 'package:dogio/src/dogio/doggo/doggos.dart';
import 'package:flutter/material.dart';
import 'package:vector_math/vector_math.dart' show Vector2;

import 'package:logging/logging.dart' hide Level;
import 'package:vector_math/vector_math.dart' show Vector2;

import '../dogio/doggo/ai_move.dart';
import '../dogio/doggo/players.dart';
import '../dogio/doggo/descriptors.dart';
import '../dogio/doggo/players.dart';

class MinesweeperScreen extends StatefulWidget {
// final GameLevel level;
Expand All @@ -39,7 +37,7 @@ class _MinesweeperScreen extends State<MinesweeperScreen>
static const _kBoardWidth = 2500.0;
static const _kBoardHeight = 1200.0;

Board _board = Board(
final Board _board = Board(
boardWidth: _kBoardWidth,
boardHeight: _kBoardHeight,
);
Expand Down Expand Up @@ -201,7 +199,7 @@ class TimerNotifier extends ChangeNotifier {
// CustomPainter is what is passed to CustomPaint and actually draws the scene
// when its `paint` method is called.
class _BoardPainter extends CustomPainter {
_BoardPainter({required this.board}) : super(repaint: TimerNotifier()) {}
_BoardPainter({required this.board}) : super(repaint: TimerNotifier());

final Board board;

Expand Down Expand Up @@ -294,8 +292,7 @@ class Board extends Object {
assert(boardHeight > 0)
// assert(rectRadius > 0),
// assert(rectMargin >= 0)
{}

;
final double boardWidth; // Number of cells in the x axis
final double boardHeight; // Number of cells in the y axis
// final double rectRadius; // Pixel radius of a rectangle (center to vertex).
Expand Down
Loading

0 comments on commit 8047e56

Please sign in to comment.