Merge branch 'main' into refactor/ball-priority

pull/183/head
Allison Ryan 4 years ago
commit 51808d3a97

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 MiB

After

Width:  |  Height:  |  Size: 9.7 MiB

@ -37,6 +37,7 @@ extension PinballGameAssetsX on PinballGame {
images.load(components.Assets.images.spaceship.saucer.keyName), images.load(components.Assets.images.spaceship.saucer.keyName),
images.load(components.Assets.images.spaceship.bridge.keyName), images.load(components.Assets.images.spaceship.bridge.keyName),
images.load(components.Assets.images.spaceship.ramp.main.keyName), images.load(components.Assets.images.spaceship.ramp.main.keyName),
images.load(components.Assets.images.spaceship.ramp.boardOpening.keyName),
images.load( images.load(
components.Assets.images.spaceship.ramp.railingBackground.keyName, components.Assets.images.spaceship.ramp.railingBackground.keyName,
), ),

@ -1,71 +1,79 @@
{ {
"@@locale": "en", "@@locale": "en",
"play": "Play", "play": "Play",
"@play": { "@play": {
"description": "Text displayed on the landing page play button" "description": "Text displayed on the landing page play button"
}, },
"howToPlay": "How to Play", "howToPlay": "How to Play",
"@howToPlay": { "@howToPlay": {
"description": "Text displayed on the landing page how to play button" "description": "Text displayed on the landing page how to play button"
}, },
"launchControls": "Launch Controls", "launchControls": "Launch Controls",
"@launchControls": { "@launchControls": {
"description": "Text displayed on the how to play dialog with the launch controls" "description": "Text displayed on the how to play dialog with the launch controls"
}, },
"flipperControls": "Flipper Controls", "flipperControls": "Flipper Controls",
"@flipperControls": { "@flipperControls": {
"description": "Text displayed on the how to play dialog with the flipper controls" "description": "Text displayed on the how to play dialog with the flipper controls"
}, },
"start": "Start", "start": "Start",
"@start": { "@start": {
"description": "Text displayed on the character selection page start button" "description": "Text displayed on the character selection page start button"
}, },
"characterSelectionTitle": "Choose your character!", "select": "Select",
"@characterSelectionTitle": { "@select": {
"description": "Title text displayed on the character selection page" "description": "Text displayed on the character selection page select button"
}, },
"gameOver": "Game Over", "characterSelectionTitle": "Choose your character!",
"@gameOver": { "@characterSelectionTitle": {
"description": "Text displayed on the ending dialog when game finishes" "description": "Title text displayed on the character selection page"
}, },
"leaderboard": "Leaderboard", "characterSelectionSubtitle": "Theres no wrong answer",
"@leaderboard": { "@characterSelectionSubtitle": {
"description": "Text displayed on the ending dialog leaderboard button" "description": "Text displayed on the selecting character dialog at game beginning"
}, },
"rank": "Rank", "gameOver": "Game Over",
"@rank": { "@gameOver": {
"description": "Text displayed on the leaderboard page header rank column" "description": "Text displayed on the ending dialog when game finishes"
}, },
"character": "Character", "leaderboard": "Leaderboard",
"@character": { "@leaderboard": {
"description": "Text displayed on the leaderboard page header character column" "description": "Text displayed on the ending dialog leaderboard button"
}, },
"username": "Username", "rank": "Rank",
"@username": { "@rank": {
"description": "Text displayed on the leaderboard page header userName column" "description": "Text displayed on the leaderboard page header rank column"
}, },
"score": "Score", "character": "Character",
"@score": { "@character": {
"description": "Text displayed on the leaderboard page header score column" "description": "Text displayed on the leaderboard page header character column"
}, },
"retry": "Retry", "username": "Username",
"@retry": { "@username": {
"description": "Text displayed on the retry button leaders board page" "description": "Text displayed on the leaderboard page header userName column"
}, },
"addUser": "Add User", "score": "Score",
"@addUser": { "@score": {
"description": "Text displayed on the add user button at ending dialog" "description": "Text displayed on the leaderboard page header score column"
}, },
"error": "Error", "retry": "Retry",
"@error": { "@retry": {
"description": "Text displayed on the ending dialog when there is any error on sending user" "description": "Text displayed on the retry button leaders board page"
}, },
"yourScore": "Your score is", "addUser": "Add User",
"@yourScore": { "@addUser": {
"description": "Text displayed on the ending dialog when game finishes to show the final score" "description": "Text displayed on the add user button at ending dialog"
}, },
"enterInitials": "Enter your initials", "error": "Error",
"@enterInitials": { "@error": {
"description": "Text displayed on the ending dialog when game finishes to ask the user for his initials" "description": "Text displayed on the ending dialog when there is any error on sending user"
} },
} "yourScore": "Your score is",
"@yourScore": {
"description": "Text displayed on the ending dialog when game finishes to show the final score"
},
"enterInitials": "Enter your initials",
"@enterInitials": {
"description": "Text displayed on the ending dialog when game finishes to ask the user for his initials"
}
}

@ -36,7 +36,7 @@ extension LeaderboardEntryDataX on LeaderboardEntryData {
rank: position.toString(), rank: position.toString(),
playerInitials: playerInitials, playerInitials: playerInitials,
score: score, score: score,
character: character.toTheme.characterAsset, character: character.toTheme.character,
); );
} }
} }

@ -122,7 +122,7 @@ class CharacterImageButton extends StatelessWidget {
), ),
child: Padding( child: Padding(
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
child: characterTheme.characterAsset.image(), child: characterTheme.character.image(),
), ),
), ),
); );

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 MiB

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

@ -283,6 +283,10 @@ class $AssetsImagesSpaceshipRailGen {
class $AssetsImagesSpaceshipRampGen { class $AssetsImagesSpaceshipRampGen {
const $AssetsImagesSpaceshipRampGen(); const $AssetsImagesSpaceshipRampGen();
/// File path: assets/images/spaceship/ramp/board-opening.png
AssetGenImage get boardOpening =>
const AssetGenImage('assets/images/spaceship/ramp/board-opening.png');
/// File path: assets/images/spaceship/ramp/main.png /// File path: assets/images/spaceship/ramp/main.png
AssetGenImage get main => AssetGenImage get main =>
const AssetGenImage('assets/images/spaceship/ramp/main.png'); const AssetGenImage('assets/images/spaceship/ramp/main.png');

@ -1,4 +1,4 @@
// ignore_for_file: avoid_renaming_method_parameters, comment_references // ignore_for_file: avoid_renaming_method_parameters
import 'dart:math' as math; import 'dart:math' as math;
@ -8,7 +8,7 @@ import 'package:pinball_components/gen/assets.gen.dart';
import 'package:pinball_components/pinball_components.dart' hide Assets; import 'package:pinball_components/pinball_components.dart' hide Assets;
/// {@template spaceship_ramp} /// {@template spaceship_ramp}
/// A [Blueprint] which creates the [_SpaceshipRampBackground]. /// A [Blueprint] which creates the ramp leading into the [Spaceship].
/// {@endtemplate} /// {@endtemplate}
class SpaceshipRamp extends Forge2DBlueprint { class SpaceshipRamp extends Forge2DBlueprint {
/// {@macro spaceship_ramp} /// {@macro spaceship_ramp}
@ -25,23 +25,28 @@ class SpaceshipRamp extends Forge2DBlueprint {
outsidePriority: 1, outsidePriority: 1,
rotation: math.pi, rotation: math.pi,
) )
..initialPosition = Vector2(1.7, 19) ..initialPosition = Vector2(1.7, 19.8)
..layer = Layer.opening; ..layer = Layer.opening;
final leftOpening = _SpaceshipRampOpening( final leftOpening = _SpaceshipRampOpening(
outsideLayer: Layer.spaceship, outsideLayer: Layer.spaceship,
outsidePriority: Ball.spaceshipPriority, outsidePriority: Ball.spaceshipPriority,
rotation: math.pi, rotation: math.pi,
) )
..initialPosition = Vector2(-13.7, 19) ..initialPosition = Vector2(-13.7, 18.6)
..layer = Layer.spaceshipEntranceRamp; ..layer = Layer.spaceshipEntranceRamp;
final spaceshipRamp = _SpaceshipRampBackground(); final spaceshipRamp = _SpaceshipRampBackground();
final spaceshipRampBoardOpeningSprite =
_SpaceshipRampBoardOpeningSpriteComponent()
..position = Vector2(3.4, -39.5);
final spaceshipRampForegroundRailing = _SpaceshipRampForegroundRailing(); final spaceshipRampForegroundRailing = _SpaceshipRampForegroundRailing();
final baseRight = _SpaceshipRampBase()..initialPosition = Vector2(1.7, 20); final baseRight = _SpaceshipRampBase()..initialPosition = Vector2(1.7, 20);
addAll([ addAll([
spaceshipRampBoardOpeningSprite,
rightOpening, rightOpening,
leftOpening, leftOpening,
baseRight, baseRight,
@ -51,8 +56,6 @@ class SpaceshipRamp extends Forge2DBlueprint {
} }
} }
/// Represents the upper left blue ramp of the [Board] with its background
/// railing.
class _SpaceshipRampBackground extends BodyComponent class _SpaceshipRampBackground extends BodyComponent
with InitialPosition, Layered { with InitialPosition, Layered {
_SpaceshipRampBackground() : super(priority: Ball.spaceshipRampPriority - 1) { _SpaceshipRampBackground() : super(priority: Ball.spaceshipRampPriority - 1) {
@ -67,7 +70,7 @@ class _SpaceshipRampBackground extends BodyComponent
final outerLeftCurveShape = BezierCurveShape( final outerLeftCurveShape = BezierCurveShape(
controlPoints: [ controlPoints: [
Vector2(-30.95, 38), Vector2(-30.75, 37.3),
Vector2(-32.5, 71.25), Vector2(-32.5, 71.25),
Vector2(-14.2, 71.25), Vector2(-14.2, 71.25),
], ],
@ -79,14 +82,22 @@ class _SpaceshipRampBackground extends BodyComponent
final outerRightCurveShape = BezierCurveShape( final outerRightCurveShape = BezierCurveShape(
controlPoints: [ controlPoints: [
outerLeftCurveShape.vertices.last, outerLeftCurveShape.vertices.last,
Vector2(4.7, 71.25), Vector2(2.5, 71.9),
Vector2(6.3, 40), Vector2(6.1, 44.9),
], ],
); );
final outerRightCurveFixtureDef = FixtureDef(outerRightCurveShape); final outerRightCurveFixtureDef = FixtureDef(outerRightCurveShape);
fixturesDef.add(outerRightCurveFixtureDef); fixturesDef.add(outerRightCurveFixtureDef);
final boardOpeningEdgeShape = EdgeShape()
..set(
outerRightCurveShape.vertices.last,
Vector2(7.3, 41.1),
);
final boardOpeningEdgeShapeFixtureDef = FixtureDef(boardOpeningEdgeShape);
fixturesDef.add(boardOpeningEdgeShapeFixtureDef);
return fixturesDef; return fixturesDef;
} }
@ -107,8 +118,8 @@ class _SpaceshipRampBackground extends BodyComponent
await super.onLoad(); await super.onLoad();
renderBody = false; renderBody = false;
await add(_SpaceshipRampBackgroundRailingSpriteComponent());
await add(_SpaceshipRampBackgroundRampSpriteComponent()); await add(_SpaceshipRampBackgroundRampSpriteComponent());
await add(_SpaceshipRampBackgroundRailingSpriteComponent());
} }
} }
@ -121,9 +132,9 @@ class _SpaceshipRampBackgroundRailingSpriteComponent extends SpriteComponent
Assets.images.spaceship.ramp.railingBackground.keyName, Assets.images.spaceship.ramp.railingBackground.keyName,
); );
this.sprite = sprite; this.sprite = sprite;
size = Vector2(38.3, 35.1); size = sprite.originalSize / 10;
anchor = Anchor.center; anchor = Anchor.center;
position = Vector2(-12.2, -54.5); position = Vector2(-11.7, -54.3);
} }
} }
@ -138,11 +149,24 @@ class _SpaceshipRampBackgroundRampSpriteComponent extends SpriteComponent
this.sprite = sprite; this.sprite = sprite;
size = sprite.originalSize / 10; size = sprite.originalSize / 10;
anchor = Anchor.center; anchor = Anchor.center;
position = Vector2(-12.2, -53.5); position = Vector2(-11.7, -53.6);
}
}
class _SpaceshipRampBoardOpeningSpriteComponent extends SpriteComponent
with HasGameRef {
@override
Future<void> onLoad() async {
await super.onLoad();
final sprite = await gameRef.loadSprite(
Assets.images.spaceship.ramp.boardOpening.keyName,
);
this.sprite = sprite;
size = sprite.originalSize / 10;
anchor = Anchor.center;
} }
} }
/// Represents the foreground of the railing upper left blue ramp.
class _SpaceshipRampForegroundRailing extends BodyComponent class _SpaceshipRampForegroundRailing extends BodyComponent
with InitialPosition, Layered { with InitialPosition, Layered {
_SpaceshipRampForegroundRailing() _SpaceshipRampForegroundRailing()
@ -167,14 +191,22 @@ class _SpaceshipRampForegroundRailing extends BodyComponent
final innerRightCurveShape = BezierCurveShape( final innerRightCurveShape = BezierCurveShape(
controlPoints: [ controlPoints: [
innerLeftCurveShape.vertices.last, innerLeftCurveShape.vertices.last,
Vector2(-1, 64.5), Vector2(-2.5, 66.2),
Vector2(0.1, 39.5), Vector2(0, 44.5),
], ],
); );
final innerRightCurveFixtureDef = FixtureDef(innerRightCurveShape); final innerRightCurveFixtureDef = FixtureDef(innerRightCurveShape);
fixturesDef.add(innerRightCurveFixtureDef); fixturesDef.add(innerRightCurveFixtureDef);
final boardOpeningEdgeShape = EdgeShape()
..set(
innerRightCurveShape.vertices.last,
Vector2(-0.85, 40.8),
);
final boardOpeningEdgeShapeFixtureDef = FixtureDef(boardOpeningEdgeShape);
fixturesDef.add(boardOpeningEdgeShapeFixtureDef);
return fixturesDef; return fixturesDef;
} }
@ -208,13 +240,12 @@ class _SpaceshipRampForegroundRailingSpriteComponent extends SpriteComponent
Assets.images.spaceship.ramp.railingForeground.keyName, Assets.images.spaceship.ramp.railingForeground.keyName,
); );
this.sprite = sprite; this.sprite = sprite;
size = Vector2(26.1, 28.3); size = sprite.originalSize / 10;
anchor = Anchor.center; anchor = Anchor.center;
position = Vector2(-12.2, -52.5); position = Vector2(-12.3, -52.5);
} }
} }
/// Represents the ground right base of the [SpaceshipRamp].
class _SpaceshipRampBase extends BodyComponent with InitialPosition, Layered { class _SpaceshipRampBase extends BodyComponent with InitialPosition, Layered {
_SpaceshipRampBase() { _SpaceshipRampBase() {
renderBody = false; renderBody = false;
@ -223,14 +254,14 @@ class _SpaceshipRampBase extends BodyComponent with InitialPosition, Layered {
@override @override
Body createBody() { Body createBody() {
const baseWidth = 6; const baseWidth = 9;
final baseShape = BezierCurveShape( final baseShape = BezierCurveShape(
controlPoints: [ controlPoints: [
Vector2(initialPosition.x - baseWidth / 2, initialPosition.y), Vector2(initialPosition.x - baseWidth / 2, initialPosition.y),
Vector2(initialPosition.x - baseWidth / 2, initialPosition.y) + Vector2(initialPosition.x - baseWidth / 2, initialPosition.y) +
Vector2(2, 2), Vector2(2, 5),
Vector2(initialPosition.x + baseWidth / 2, initialPosition.y) + Vector2(initialPosition.x + baseWidth / 2, initialPosition.y) +
Vector2(-2, 2), Vector2(-2, 5),
Vector2(initialPosition.x + baseWidth / 2, initialPosition.y) Vector2(initialPosition.x + baseWidth / 2, initialPosition.y)
], ],
); );
@ -267,7 +298,7 @@ class _SpaceshipRampOpening extends RampOpening {
final double _rotation; final double _rotation;
static final Vector2 _size = Vector2(_SpaceshipRampBackground.width / 4, .1); static final Vector2 _size = Vector2(_SpaceshipRampBackground.width / 3, .1);
@override @override
Shape get shape { Shape get shape {

@ -12,8 +12,6 @@ extension BodyTrace on BodyComponent {
unawaited( unawaited(
mounted.whenComplete(() { mounted.whenComplete(() {
children.whereType<SpriteComponent>().first.setOpacity(0.5);
descendants().whereType<JointAnchor>().forEach((anchor) { descendants().whereType<JointAnchor>().forEach((anchor) {
final fixtureDef = FixtureDef(CircleShape()..radius = 0.5); final fixtureDef = FixtureDef(CircleShape()..radius = 0.5);
anchor.body.createFixture(fixtureDef); anchor.body.createFixture(fixtureDef);
@ -32,9 +30,13 @@ mixin Traceable on Forge2DGame {
}) async { }) async {
if (trace) { if (trace) {
await ready(); await ready();
children descendants()
.whereType<BodyComponent>() .whereType<BodyComponent>()
.forEach((bodyComponent) => bodyComponent.trace()); .forEach((bodyComponent) => bodyComponent.trace());
descendants()
.whereType<SpriteComponent>()
.forEach((sprite) => sprite.setOpacity(0.5));
} }
} }
} }

@ -17,6 +17,8 @@ void main() {
addEffectsStories(dashbook); addEffectsStories(dashbook);
addFlipperStories(dashbook); addFlipperStories(dashbook);
addSpaceshipStories(dashbook); addSpaceshipStories(dashbook);
addSpaceshipRampStories(dashbook);
addSpaceshipRailStories(dashbook);
addBaseboardStories(dashbook); addBaseboardStories(dashbook);
addChromeDinoStories(dashbook); addChromeDinoStories(dashbook);
addDashNestBumperStories(dashbook); addDashNestBumperStories(dashbook);
@ -28,8 +30,6 @@ void main() {
addZoomStories(dashbook); addZoomStories(dashbook);
addBoundariesStories(dashbook); addBoundariesStories(dashbook);
addGoogleWordStories(dashbook); addGoogleWordStories(dashbook);
addSpaceshipRampStories(dashbook);
addSpaceshipRailStories(dashbook);
addLaunchRampStories(dashbook); addLaunchRampStories(dashbook);
addScoreTextStories(dashbook); addScoreTextStories(dashbook);

@ -14,7 +14,7 @@ class SpaceshipRampGame extends BasicBallGame {
); );
static const info = ''' static const info = '''
Shows how SpaceshipRamp are rendered. Shows how SpaceshipRamp is rendered.
- Activate the "trace" parameter to overlay the body. - Activate the "trace" parameter to overlay the body.
- Tap anywhere on the screen to spawn a ball into the game. - Tap anywhere on the screen to spawn a ball into the game.
@ -23,12 +23,8 @@ class SpaceshipRampGame extends BasicBallGame {
@override @override
Future<void> onLoad() async { Future<void> onLoad() async {
await super.onLoad(); await super.onLoad();
await addFromBlueprint(SpaceshipRamp());
camera.followVector2(Vector2(-10, -20)); camera.followVector2(Vector2(-12, -50));
final spaceshipRamp = SpaceshipRamp();
unawaited(addFromBlueprint(spaceshipRamp));
await traceAllBodies(); await traceAllBodies();
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 913 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 894 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 844 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 894 KiB

After

Width:  |  Height:  |  Size: 844 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

@ -1,5 +1,6 @@
// ignore_for_file: cascade_invocations // ignore_for_file: cascade_invocations
import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:flame_test/flame_test.dart'; import 'package:flame_test/flame_test.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:pinball_components/pinball_components.dart'; import 'package:pinball_components/pinball_components.dart';
@ -8,20 +9,22 @@ import '../../helpers/helpers.dart';
void main() { void main() {
group('SpaceshipRamp', () { group('SpaceshipRamp', () {
TestWidgetsFlutterBinding.ensureInitialized(); final tester = FlameTester(TestGame.new);
final flameTester = FlameTester(TestGame.new);
flameTester.test( tester.testGameWidget(
'loads correctly', 'renders correctly',
(game) async { setUp: (game, tester) async {
final spaceshipEntranceRamp = SpaceshipRamp(); await game.addFromBlueprint(SpaceshipRamp());
await game.addFromBlueprint(spaceshipEntranceRamp);
await game.ready(); await game.ready();
game.camera.followVector2(Vector2(-13, -50));
for (final element in spaceshipEntranceRamp.components) {
expect(game.contains(element), isTrue);
}
}, },
// TODO(allisonryan0002): enable test when workflows are fixed.
// verify: (game, tester) async {
// await expectLater(
// find.byGame<Forge2DGame>(),
// matchesGoldenFile('golden/spaceship-ramp.png'),
// );
// },
); );
}); });
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 274 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 308 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 223 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

@ -3,15 +3,88 @@
/// FlutterGen /// FlutterGen
/// ***************************************************** /// *****************************************************
// ignore_for_file: directives_ordering,unnecessary_import
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
class $AssetsImagesGen { class $AssetsImagesGen {
const $AssetsImagesGen(); const $AssetsImagesGen();
AssetGenImage get android => const AssetGenImage('assets/images/android.png'); $AssetsImagesAndroidGen get android => const $AssetsImagesAndroidGen();
AssetGenImage get dash => const AssetGenImage('assets/images/dash.png'); $AssetsImagesDashGen get dash => const $AssetsImagesDashGen();
AssetGenImage get dino => const AssetGenImage('assets/images/dino.png'); $AssetsImagesDinoGen get dino => const $AssetsImagesDinoGen();
AssetGenImage get sparky => const AssetGenImage('assets/images/sparky.png');
/// File path: assets/images/pinball_button.png
AssetGenImage get pinballButton =>
const AssetGenImage('assets/images/pinball_button.png');
/// File path: assets/images/select_character_background.png
AssetGenImage get selectCharacterBackground =>
const AssetGenImage('assets/images/select_character_background.png');
$AssetsImagesSparkyGen get sparky => const $AssetsImagesSparkyGen();
}
class $AssetsImagesAndroidGen {
const $AssetsImagesAndroidGen();
/// File path: assets/images/android/background.png
AssetGenImage get background =>
const AssetGenImage('assets/images/android/background.png');
/// File path: assets/images/android/character.png
AssetGenImage get character =>
const AssetGenImage('assets/images/android/character.png');
/// File path: assets/images/android/icon.png
AssetGenImage get icon =>
const AssetGenImage('assets/images/android/icon.png');
}
class $AssetsImagesDashGen {
const $AssetsImagesDashGen();
/// File path: assets/images/dash/background.png
AssetGenImage get background =>
const AssetGenImage('assets/images/dash/background.png');
/// File path: assets/images/dash/character.png
AssetGenImage get character =>
const AssetGenImage('assets/images/dash/character.png');
/// File path: assets/images/dash/icon.png
AssetGenImage get icon => const AssetGenImage('assets/images/dash/icon.png');
}
class $AssetsImagesDinoGen {
const $AssetsImagesDinoGen();
/// File path: assets/images/dino/background.png
AssetGenImage get background =>
const AssetGenImage('assets/images/dino/background.png');
/// File path: assets/images/dino/character.png
AssetGenImage get character =>
const AssetGenImage('assets/images/dino/character.png');
/// File path: assets/images/dino/icon.png
AssetGenImage get icon => const AssetGenImage('assets/images/dino/icon.png');
}
class $AssetsImagesSparkyGen {
const $AssetsImagesSparkyGen();
/// File path: assets/images/sparky/background.png
AssetGenImage get background =>
const AssetGenImage('assets/images/sparky/background.png');
/// File path: assets/images/sparky/character.png
AssetGenImage get character =>
const AssetGenImage('assets/images/sparky/character.png');
/// File path: assets/images/sparky/icon.png
AssetGenImage get icon =>
const AssetGenImage('assets/images/sparky/icon.png');
} }
class Assets { class Assets {

@ -8,9 +8,18 @@ class AndroidTheme extends CharacterTheme {
/// {@macro android_theme} /// {@macro android_theme}
const AndroidTheme(); const AndroidTheme();
@override
String get name => 'Android';
@override @override
Color get ballColor => Colors.green; Color get ballColor => Colors.green;
@override @override
AssetGenImage get characterAsset => Assets.images.android; AssetGenImage get character => Assets.images.android.character;
@override
AssetGenImage get background => Assets.images.android.background;
@override
AssetGenImage get icon => Assets.images.android.icon;
} }

@ -12,12 +12,27 @@ abstract class CharacterTheme extends Equatable {
/// {@macro character_theme} /// {@macro character_theme}
const CharacterTheme(); const CharacterTheme();
/// Name of character.
String get name;
/// Ball color for this theme. /// Ball color for this theme.
Color get ballColor; Color get ballColor;
/// Asset for the theme character. /// Asset for the theme character.
AssetGenImage get characterAsset; AssetGenImage get character;
/// Asset for the background.
AssetGenImage get background;
/// Icon asset.
AssetGenImage get icon;
@override @override
List<Object?> get props => [ballColor]; List<Object?> get props => [
name,
ballColor,
character,
background,
icon,
];
} }

@ -8,9 +8,18 @@ class DashTheme extends CharacterTheme {
/// {@macro dash_theme} /// {@macro dash_theme}
const DashTheme(); const DashTheme();
@override
String get name => 'Dash';
@override @override
Color get ballColor => Colors.blue; Color get ballColor => Colors.blue;
@override @override
AssetGenImage get characterAsset => Assets.images.dash; AssetGenImage get character => Assets.images.dash.character;
@override
AssetGenImage get background => Assets.images.dash.background;
@override
AssetGenImage get icon => Assets.images.dash.icon;
} }

@ -8,9 +8,18 @@ class DinoTheme extends CharacterTheme {
/// {@macro dino_theme} /// {@macro dino_theme}
const DinoTheme(); const DinoTheme();
@override
String get name => 'Dino';
@override @override
Color get ballColor => Colors.grey; Color get ballColor => Colors.grey;
@override @override
AssetGenImage get characterAsset => Assets.images.dino; AssetGenImage get character => Assets.images.dino.character;
@override
AssetGenImage get background => Assets.images.dino.background;
@override
AssetGenImage get icon => Assets.images.dino.icon;
} }

@ -12,5 +12,14 @@ class SparkyTheme extends CharacterTheme {
Color get ballColor => Colors.orange; Color get ballColor => Colors.orange;
@override @override
AssetGenImage get characterAsset => Assets.images.sparky; String get name => 'Sparky';
@override
AssetGenImage get character => Assets.images.sparky.character;
@override
AssetGenImage get background => Assets.images.sparky.background;
@override
AssetGenImage get icon => Assets.images.sparky.icon;
} }

@ -21,9 +21,15 @@ flutter:
generate: true generate: true
assets: assets:
- assets/images/ - assets/images/
- assets/images/android/
- assets/images/dash/
- assets/images/dino/
- assets/images/sparky/
flutter_gen: flutter_gen:
assets: assets:
package_parameter_enabled: true package_parameter_enabled: true
output: lib/src/generated/ output: lib/src/generated/
line_length: 80 line_length: 80
integrations:
flutter_svg: true

@ -18,8 +18,22 @@ void main() {
expect(AndroidTheme().ballColor, equals(Colors.green)); expect(AndroidTheme().ballColor, equals(Colors.green));
}); });
test('characterAsset is correct', () { test('character asset is correct', () {
expect(AndroidTheme().characterAsset, equals(Assets.images.android)); expect(
AndroidTheme().character,
equals(Assets.images.android.character),
);
});
test('background asset is correct', () {
expect(
AndroidTheme().background,
equals(Assets.images.android.background),
);
});
test('icon asset is correct', () {
expect(AndroidTheme().icon, equals(Assets.images.android.icon));
}); });
}); });
} }

@ -18,8 +18,22 @@ void main() {
expect(DashTheme().ballColor, equals(Colors.blue)); expect(DashTheme().ballColor, equals(Colors.blue));
}); });
test('characterAsset is correct', () { test('character asset is correct', () {
expect(DashTheme().characterAsset, equals(Assets.images.dash)); expect(
DashTheme().character,
equals(Assets.images.dash.character),
);
});
test('background asset is correct', () {
expect(
DashTheme().background,
equals(Assets.images.dash.background),
);
});
test('icon asset is correct', () {
expect(DashTheme().icon, equals(Assets.images.dash.icon));
}); });
}); });
} }

@ -18,8 +18,22 @@ void main() {
expect(DinoTheme().ballColor, equals(Colors.grey)); expect(DinoTheme().ballColor, equals(Colors.grey));
}); });
test('characterAsset is correct', () { test('character asset is correct', () {
expect(DinoTheme().characterAsset, equals(Assets.images.dino)); expect(
DinoTheme().character,
equals(Assets.images.dino.character),
);
});
test('background asset is correct', () {
expect(
DinoTheme().background,
equals(Assets.images.dino.background),
);
});
test('icon asset is correct', () {
expect(DinoTheme().icon, equals(Assets.images.dino.icon));
}); });
}); });
} }

@ -18,8 +18,22 @@ void main() {
expect(SparkyTheme().ballColor, equals(Colors.orange)); expect(SparkyTheme().ballColor, equals(Colors.orange));
}); });
test('characterAsset is correct', () { test('character asset is correct', () {
expect(SparkyTheme().characterAsset, equals(Assets.images.sparky)); expect(
SparkyTheme().character,
equals(Assets.images.sparky.character),
);
});
test('background asset is correct', () {
expect(
SparkyTheme().background,
equals(Assets.images.sparky.background),
);
});
test('icon asset is correct', () {
expect(SparkyTheme().icon, equals(Assets.images.sparky.icon));
}); });
}); });
} }

@ -30,7 +30,7 @@ void main() {
rank: '1', rank: '1',
playerInitials: 'ABC', playerInitials: 'ABC',
score: 1500, score: 1500,
character: DashTheme().characterAsset, character: DashTheme().character,
); );
test( test(

@ -121,7 +121,7 @@ void main() {
rank: '1', rank: '1',
playerInitials: 'ABC', playerInitials: 'ABC',
score: 10000, score: 10000,
character: DashTheme().characterAsset, character: DashTheme().character,
), ),
], ],
), ),

Loading…
Cancel
Save