Merge branch 'main' into feat/google-rollovers

pull/407/head
Allison Ryan 3 years ago committed by GitHub
commit 16323a824f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -15,9 +15,9 @@ class $AssetsImagesGen {
$AssetsImagesBallGen get ball => const $AssetsImagesBallGen(); $AssetsImagesBallGen get ball => const $AssetsImagesBallGen();
$AssetsImagesBaseboardGen get baseboard => const $AssetsImagesBaseboardGen(); $AssetsImagesBaseboardGen get baseboard => const $AssetsImagesBaseboardGen();
/// File path: assets/images/board-background.png /// File path: assets/images/board_background.png
AssetGenImage get boardBackground => AssetGenImage get boardBackground =>
const AssetGenImage('assets/images/board-background.png'); const AssetGenImage('assets/images/board_background.png');
$AssetsImagesBoundaryGen get boundary => const $AssetsImagesBoundaryGen(); $AssetsImagesBoundaryGen get boundary => const $AssetsImagesBoundaryGen();
$AssetsImagesDashGen get dash => const $AssetsImagesDashGen(); $AssetsImagesDashGen get dash => const $AssetsImagesDashGen();
@ -61,9 +61,9 @@ class $AssetsImagesAndroidGen {
class $AssetsImagesBackboxGen { class $AssetsImagesBackboxGen {
const $AssetsImagesBackboxGen(); const $AssetsImagesBackboxGen();
/// File path: assets/images/backbox/display-divider.png /// File path: assets/images/backbox/display_divider.png
AssetGenImage get displayDivider => AssetGenImage get displayDivider =>
const AssetGenImage('assets/images/backbox/display-divider.png'); const AssetGenImage('assets/images/backbox/display_divider.png');
/// File path: assets/images/backbox/display_title_decoration.png /// File path: assets/images/backbox/display_title_decoration.png
AssetGenImage get displayTitleDecoration => AssetGenImage get displayTitleDecoration =>
@ -101,13 +101,13 @@ class $AssetsImagesBoundaryGen {
AssetGenImage get bottom => AssetGenImage get bottom =>
const AssetGenImage('assets/images/boundary/bottom.png'); const AssetGenImage('assets/images/boundary/bottom.png');
/// File path: assets/images/boundary/outer-bottom.png
AssetGenImage get outerBottom =>
const AssetGenImage('assets/images/boundary/outer-bottom.png');
/// File path: assets/images/boundary/outer.png /// File path: assets/images/boundary/outer.png
AssetGenImage get outer => AssetGenImage get outer =>
const AssetGenImage('assets/images/boundary/outer.png'); const AssetGenImage('assets/images/boundary/outer.png');
/// File path: assets/images/boundary/outer_bottom.png
AssetGenImage get outerBottom =>
const AssetGenImage('assets/images/boundary/outer_bottom.png');
} }
class $AssetsImagesDashGen { class $AssetsImagesDashGen {
@ -126,33 +126,33 @@ class $AssetsImagesDinoGen {
$AssetsImagesDinoAnimatronicGen get animatronic => $AssetsImagesDinoAnimatronicGen get animatronic =>
const $AssetsImagesDinoAnimatronicGen(); const $AssetsImagesDinoAnimatronicGen();
/// File path: assets/images/dino/bottom-wall.png /// File path: assets/images/dino/bottom_wall.png
AssetGenImage get bottomWall => AssetGenImage get bottomWall =>
const AssetGenImage('assets/images/dino/bottom-wall.png'); const AssetGenImage('assets/images/dino/bottom_wall.png');
/// File path: assets/images/dino/top-wall-tunnel.png /// File path: assets/images/dino/top_wall.png
AssetGenImage get topWallTunnel =>
const AssetGenImage('assets/images/dino/top-wall-tunnel.png');
/// File path: assets/images/dino/top-wall.png
AssetGenImage get topWall => AssetGenImage get topWall =>
const AssetGenImage('assets/images/dino/top-wall.png'); const AssetGenImage('assets/images/dino/top_wall.png');
/// File path: assets/images/dino/top_wall_tunnel.png
AssetGenImage get topWallTunnel =>
const AssetGenImage('assets/images/dino/top_wall_tunnel.png');
} }
class $AssetsImagesFlapperGen { class $AssetsImagesFlapperGen {
const $AssetsImagesFlapperGen(); const $AssetsImagesFlapperGen();
/// File path: assets/images/flapper/back-support.png /// File path: assets/images/flapper/back_support.png
AssetGenImage get backSupport => AssetGenImage get backSupport =>
const AssetGenImage('assets/images/flapper/back-support.png'); const AssetGenImage('assets/images/flapper/back_support.png');
/// File path: assets/images/flapper/flap.png /// File path: assets/images/flapper/flap.png
AssetGenImage get flap => AssetGenImage get flap =>
const AssetGenImage('assets/images/flapper/flap.png'); const AssetGenImage('assets/images/flapper/flap.png');
/// File path: assets/images/flapper/front-support.png /// File path: assets/images/flapper/front_support.png
AssetGenImage get frontSupport => AssetGenImage get frontSupport =>
const AssetGenImage('assets/images/flapper/front-support.png'); const AssetGenImage('assets/images/flapper/front_support.png');
} }
class $AssetsImagesFlipperGen { class $AssetsImagesFlipperGen {
@ -203,13 +203,13 @@ class $AssetsImagesKickerGen {
class $AssetsImagesLaunchRampGen { class $AssetsImagesLaunchRampGen {
const $AssetsImagesLaunchRampGen(); const $AssetsImagesLaunchRampGen();
/// File path: assets/images/launch_ramp/background-railing.png /// File path: assets/images/launch_ramp/background_railing.png
AssetGenImage get backgroundRailing => AssetGenImage get backgroundRailing =>
const AssetGenImage('assets/images/launch_ramp/background-railing.png'); const AssetGenImage('assets/images/launch_ramp/background_railing.png');
/// File path: assets/images/launch_ramp/foreground-railing.png /// File path: assets/images/launch_ramp/foreground_railing.png
AssetGenImage get foregroundRailing => AssetGenImage get foregroundRailing =>
const AssetGenImage('assets/images/launch_ramp/foreground-railing.png'); const AssetGenImage('assets/images/launch_ramp/foreground_railing.png');
/// File path: assets/images/launch_ramp/ramp.png /// File path: assets/images/launch_ramp/ramp.png
AssetGenImage get ramp => AssetGenImage get ramp =>
@ -253,21 +253,21 @@ class $AssetsImagesPlungerGen {
class $AssetsImagesScoreGen { class $AssetsImagesScoreGen {
const $AssetsImagesScoreGen(); const $AssetsImagesScoreGen();
/// File path: assets/images/score/five-thousand.png /// File path: assets/images/score/five_thousand.png
AssetGenImage get fiveThousand => AssetGenImage get fiveThousand =>
const AssetGenImage('assets/images/score/five-thousand.png'); const AssetGenImage('assets/images/score/five_thousand.png');
/// File path: assets/images/score/one-million.png /// File path: assets/images/score/one_million.png
AssetGenImage get oneMillion => AssetGenImage get oneMillion =>
const AssetGenImage('assets/images/score/one-million.png'); const AssetGenImage('assets/images/score/one_million.png');
/// File path: assets/images/score/twenty-thousand.png /// File path: assets/images/score/twenty_thousand.png
AssetGenImage get twentyThousand => AssetGenImage get twentyThousand =>
const AssetGenImage('assets/images/score/twenty-thousand.png'); const AssetGenImage('assets/images/score/twenty_thousand.png');
/// File path: assets/images/score/two-hundred-thousand.png /// File path: assets/images/score/two_hundred_thousand.png
AssetGenImage get twoHundredThousand => AssetGenImage get twoHundredThousand =>
const AssetGenImage('assets/images/score/two-hundred-thousand.png'); const AssetGenImage('assets/images/score/two_hundred_thousand.png');
} }
class $AssetsImagesSignpostGen { class $AssetsImagesSignpostGen {
@ -364,21 +364,21 @@ class $AssetsImagesAndroidRampGen {
$AssetsImagesAndroidRampArrowGen get arrow => $AssetsImagesAndroidRampArrowGen get arrow =>
const $AssetsImagesAndroidRampArrowGen(); const $AssetsImagesAndroidRampArrowGen();
/// File path: assets/images/android/ramp/board-opening.png /// File path: assets/images/android/ramp/board_opening.png
AssetGenImage get boardOpening => AssetGenImage get boardOpening =>
const AssetGenImage('assets/images/android/ramp/board-opening.png'); const AssetGenImage('assets/images/android/ramp/board_opening.png');
/// File path: assets/images/android/ramp/main.png /// File path: assets/images/android/ramp/main.png
AssetGenImage get main => AssetGenImage get main =>
const AssetGenImage('assets/images/android/ramp/main.png'); const AssetGenImage('assets/images/android/ramp/main.png');
/// File path: assets/images/android/ramp/railing-background.png /// File path: assets/images/android/ramp/railing_background.png
AssetGenImage get railingBackground => AssetGenImage get railingBackground =>
const AssetGenImage('assets/images/android/ramp/railing-background.png'); const AssetGenImage('assets/images/android/ramp/railing_background.png');
/// File path: assets/images/android/ramp/railing-foreground.png /// File path: assets/images/android/ramp/railing_foreground.png
AssetGenImage get railingForeground => AssetGenImage get railingForeground =>
const AssetGenImage('assets/images/android/ramp/railing-foreground.png'); const AssetGenImage('assets/images/android/ramp/railing_foreground.png');
} }
class $AssetsImagesAndroidSpaceshipGen { class $AssetsImagesAndroidSpaceshipGen {
@ -388,9 +388,9 @@ class $AssetsImagesAndroidSpaceshipGen {
AssetGenImage get animatronic => AssetGenImage get animatronic =>
const AssetGenImage('assets/images/android/spaceship/animatronic.png'); const AssetGenImage('assets/images/android/spaceship/animatronic.png');
/// File path: assets/images/android/spaceship/light-beam.png /// File path: assets/images/android/spaceship/light_beam.png
AssetGenImage get lightBeam => AssetGenImage get lightBeam =>
const AssetGenImage('assets/images/android/spaceship/light-beam.png'); const AssetGenImage('assets/images/android/spaceship/light_beam.png');
/// File path: assets/images/android/spaceship/saucer.png /// File path: assets/images/android/spaceship/saucer.png
AssetGenImage get saucer => AssetGenImage get saucer =>

@ -3,6 +3,7 @@ import 'dart:math' as math;
import 'package:flame/components.dart'; import 'package:flame/components.dart';
import 'package:flame_forge2d/flame_forge2d.dart'; import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:pinball_components/pinball_components.dart'; import 'package:pinball_components/pinball_components.dart';
import 'package:pinball_flame/pinball_flame.dart';
/// {@template baseboard} /// {@template baseboard}
/// Wing-shaped board piece to corral the [Ball] towards the [Flipper]s. /// Wing-shaped board piece to corral the [Ball] towards the [Flipper]s.

@ -28,7 +28,6 @@ export 'multiplier/multiplier.dart';
export 'plunger.dart'; export 'plunger.dart';
export 'rocket.dart'; export 'rocket.dart';
export 'score_component/score_component.dart'; export 'score_component/score_component.dart';
export 'shapes/shapes.dart';
export 'signpost/signpost.dart'; export 'signpost/signpost.dart';
export 'skill_shot/skill_shot.dart'; export 'skill_shot/skill_shot.dart';
export 'slingshot.dart'; export 'slingshot.dart';

@ -17,8 +17,6 @@ dependencies:
ref: a50d4a1e7d9eaf66726ed1bb9894c9d495547d8f ref: a50d4a1e7d9eaf66726ed1bb9894c9d495547d8f
flutter: flutter:
sdk: flutter sdk: flutter
geometry:
path: ../geometry
intl: ^0.17.0 intl: ^0.17.0
pinball_flame: pinball_flame:
path: ../pinball_flame path: ../pinball_flame

@ -40,7 +40,7 @@ void main() {
verify: (game, tester) async { verify: (game, tester) async {
await expectLater( await expectLater(
find.byGame<TestGame>(), find.byGame<TestGame>(),
matchesGoldenFile('golden/board-background.png'), matchesGoldenFile('golden/board_background.png'),
); );
}, },
); );

@ -37,7 +37,7 @@ void main() {
verify: (game, tester) async { verify: (game, tester) async {
await expectLater( await expectLater(
find.byGame<TestGame>(), find.byGame<TestGame>(),
matchesGoldenFile('golden/dino-walls.png'), matchesGoldenFile('golden/dino_walls.png'),
); );
}, },
); );

@ -36,7 +36,7 @@ void main() {
verify: (game, tester) async { verify: (game, tester) async {
await expectLater( await expectLater(
find.byGame<TestGame>(), find.byGame<TestGame>(),
matchesGoldenFile('golden/launch-ramp.png'), matchesGoldenFile('golden/launch_ramp.png'),
); );
}, },
); );

@ -122,7 +122,7 @@ void main() {
await expectLater( await expectLater(
find.byGame<_TestGame>(), find.byGame<_TestGame>(),
matchesGoldenFile('../golden/multipliers/x2-lit.png'), matchesGoldenFile('../golden/multipliers/x2_lit.png'),
); );
}, },
); );
@ -162,7 +162,7 @@ void main() {
await expectLater( await expectLater(
find.byGame<_TestGame>(), find.byGame<_TestGame>(),
matchesGoldenFile('../golden/multipliers/x2-dimmed.png'), matchesGoldenFile('../golden/multipliers/x2_dimmed.png'),
); );
}, },
); );
@ -206,7 +206,7 @@ void main() {
await expectLater( await expectLater(
find.byGame<_TestGame>(), find.byGame<_TestGame>(),
matchesGoldenFile('../golden/multipliers/x3-lit.png'), matchesGoldenFile('../golden/multipliers/x3_lit.png'),
); );
}, },
); );
@ -246,7 +246,7 @@ void main() {
await expectLater( await expectLater(
find.byGame<_TestGame>(), find.byGame<_TestGame>(),
matchesGoldenFile('../golden/multipliers/x3-dimmed.png'), matchesGoldenFile('../golden/multipliers/x3_dimmed.png'),
); );
}, },
); );
@ -290,7 +290,7 @@ void main() {
await expectLater( await expectLater(
find.byGame<_TestGame>(), find.byGame<_TestGame>(),
matchesGoldenFile('../golden/multipliers/x4-lit.png'), matchesGoldenFile('../golden/multipliers/x4_lit.png'),
); );
}, },
); );
@ -330,7 +330,7 @@ void main() {
await expectLater( await expectLater(
find.byGame<_TestGame>(), find.byGame<_TestGame>(),
matchesGoldenFile('../golden/multipliers/x4-dimmed.png'), matchesGoldenFile('../golden/multipliers/x4_dimmed.png'),
); );
}, },
); );
@ -374,7 +374,7 @@ void main() {
await expectLater( await expectLater(
find.byGame<_TestGame>(), find.byGame<_TestGame>(),
matchesGoldenFile('../golden/multipliers/x5-lit.png'), matchesGoldenFile('../golden/multipliers/x5_lit.png'),
); );
}, },
); );
@ -414,7 +414,7 @@ void main() {
await expectLater( await expectLater(
find.byGame<_TestGame>(), find.byGame<_TestGame>(),
matchesGoldenFile('../golden/multipliers/x5-dimmed.png'), matchesGoldenFile('../golden/multipliers/x5_dimmed.png'),
); );
}, },
); );
@ -458,7 +458,7 @@ void main() {
await expectLater( await expectLater(
find.byGame<_TestGame>(), find.byGame<_TestGame>(),
matchesGoldenFile('../golden/multipliers/x6-lit.png'), matchesGoldenFile('../golden/multipliers/x6_lit.png'),
); );
}, },
); );
@ -498,7 +498,7 @@ void main() {
await expectLater( await expectLater(
find.byGame<_TestGame>(), find.byGame<_TestGame>(),
matchesGoldenFile('../golden/multipliers/x6-dimmed.png'), matchesGoldenFile('../golden/multipliers/x6_dimmed.png'),
); );
}, },
); );

@ -1,66 +0,0 @@
import 'dart:math' as math;
import 'package:flame/extensions.dart';
import 'package:flame/game.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pinball_components/src/components/components.dart';
void main() {
group('ArcShape', () {
test('can be instantiated', () {
expect(
ArcShape(
center: Vector2.zero(),
arcRadius: 10,
angle: 2 * math.pi,
),
isNotNull,
);
});
group('copyWith', () {
test(
'copies correctly '
'when no argument specified', () {
final arcShape = ArcShape(
center: Vector2.zero(),
arcRadius: 10,
angle: 2 * math.pi,
);
final arcShapeCopied = arcShape.copyWith();
for (var index = 0; index < arcShape.vertices.length; index++) {
expect(
arcShape.vertices[index],
equals(arcShapeCopied.vertices[index]),
);
}
});
test(
'copies correctly '
'when all arguments specified', () {
final arcShapeExpected = ArcShape(
center: Vector2.all(10),
arcRadius: 15,
angle: 2 * math.pi,
);
final arcShapeCopied = ArcShape(
center: Vector2.zero(),
arcRadius: 10,
angle: math.pi,
).copyWith(
center: Vector2.all(10),
arcRadius: 15,
angle: 2 * math.pi,
);
for (var index = 0; index < arcShapeCopied.vertices.length; index++) {
expect(
arcShapeCopied.vertices[index],
equals(arcShapeExpected.vertices[index]),
);
}
});
});
});
}

@ -1,51 +0,0 @@
import 'dart:math' as math;
import 'package:flame/extensions.dart';
import 'package:flame/game.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pinball_components/src/components/components.dart';
void main() {
group('BezierCurveShape', () {
final controlPoints = [
Vector2(0, 0),
Vector2(10, 0),
Vector2(0, 10),
Vector2(10, 10),
];
test('can be instantiated', () {
expect(
BezierCurveShape(
controlPoints: controlPoints,
),
isNotNull,
);
});
group('rotate', () {
test('returns vertices rotated', () {
const rotationAngle = 2 * math.pi;
final controlPoints = [
Vector2(0, 0),
Vector2(10, 0),
Vector2(0, 10),
Vector2(10, 10),
];
final bezierCurveShape = BezierCurveShape(
controlPoints: controlPoints,
);
final bezierCurveShapeRotated = BezierCurveShape(
controlPoints: controlPoints,
)..rotate(rotationAngle);
for (var index = 0; index < bezierCurveShape.vertices.length; index++) {
expect(
bezierCurveShape.vertices[index]..rotate(rotationAngle),
equals(bezierCurveShapeRotated.vertices[index]),
);
}
});
});
});
}

@ -1,83 +0,0 @@
import 'dart:math' as math;
import 'package:flame/extensions.dart';
import 'package:flame/game.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pinball_components/src/components/components.dart';
void main() {
group('EllipseShape', () {
test('can be instantiated', () {
expect(
EllipseShape(
center: Vector2.zero(),
majorRadius: 10,
minorRadius: 8,
),
isNotNull,
);
});
group('rotate', () {
test('returns vertices rotated', () {
const rotationAngle = 2 * math.pi;
final ellipseShape = EllipseShape(
center: Vector2.zero(),
majorRadius: 10,
minorRadius: 8,
);
final ellipseShapeRotated = EllipseShape(
center: Vector2.zero(),
majorRadius: 10,
minorRadius: 8,
)..rotate(rotationAngle);
for (var index = 0; index < ellipseShape.vertices.length; index++) {
expect(
ellipseShape.vertices[index]..rotate(rotationAngle),
equals(ellipseShapeRotated.vertices[index]),
);
}
});
});
group('copyWith', () {
test('returns same shape when no properties are passed', () {
final ellipseShape = EllipseShape(
center: Vector2.zero(),
majorRadius: 10,
minorRadius: 8,
);
final ellipseShapeCopied = ellipseShape.copyWith();
for (var index = 0; index < ellipseShape.vertices.length; index++) {
expect(
ellipseShape.vertices[index],
equals(ellipseShapeCopied.vertices[index]),
);
}
});
test('returns object with updated properties when are passed', () {
final ellipseShapeExpected = EllipseShape(
center: Vector2.all(10),
majorRadius: 10,
minorRadius: 8,
);
final ellipseShapeCopied = EllipseShape(
center: Vector2.zero(),
majorRadius: 10,
minorRadius: 8,
).copyWith(center: Vector2.all(10));
for (var index = 0;
index < ellipseShapeCopied.vertices.length;
index++) {
expect(
ellipseShapeCopied.vertices[index],
equals(ellipseShapeExpected.vertices[index]),
);
}
});
});
});
}

@ -35,7 +35,7 @@ void main() {
verify: (game, tester) async { verify: (game, tester) async {
await expectLater( await expectLater(
find.byGame<TestGame>(), find.byGame<TestGame>(),
matchesGoldenFile('golden/spaceship-rail.png'), matchesGoldenFile('golden/spaceship_rail.png'),
); );
}, },
); );

@ -42,7 +42,7 @@ void main() {
verify: (game, tester) async { verify: (game, tester) async {
await expectLater( await expectLater(
find.byGame<TestGame>(), find.byGame<TestGame>(),
matchesGoldenFile('../golden/sparky-computer.png'), matchesGoldenFile('../golden/sparky_computer.png'),
); );
}, },
); );

@ -8,4 +8,5 @@ export 'src/keyboard_input_controller.dart';
export 'src/layer.dart'; export 'src/layer.dart';
export 'src/parent_is_a.dart'; export 'src/parent_is_a.dart';
export 'src/pinball_forge2d_game.dart'; export 'src/pinball_forge2d_game.dart';
export 'src/shapes/shapes.dart';
export 'src/sprite_animation.dart'; export 'src/sprite_animation.dart';

@ -35,17 +35,4 @@ class ArcShape extends ChainShape {
/// Angle in radians to rotate the arc around its [center]. /// Angle in radians to rotate the arc around its [center].
final double rotation; final double rotation;
ArcShape copyWith({
Vector2? center,
double? arcRadius,
double? angle,
double? rotation,
}) =>
ArcShape(
center: center ?? this.center,
arcRadius: arcRadius ?? this.arcRadius,
angle: angle ?? this.angle,
rotation: rotation ?? this.rotation,
);
} }

@ -1,4 +1,3 @@
import 'package:flame/extensions.dart';
import 'package:flame_forge2d/flame_forge2d.dart'; import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:geometry/geometry.dart'; import 'package:geometry/geometry.dart';
@ -18,9 +17,4 @@ class BezierCurveShape extends ChainShape {
/// First and last [controlPoints] set the beginning and end of the curve, /// First and last [controlPoints] set the beginning and end of the curve,
/// inner points between them set its final shape. /// inner points between them set its final shape.
final List<Vector2> controlPoints; final List<Vector2> controlPoints;
/// Rotates the bezier curve by a given [angle] in radians.
void rotate(double angle) {
vertices.map((vector) => vector..rotate(angle)).toList();
}
} }

@ -34,17 +34,8 @@ class EllipseShape extends ChainShape {
/// Rotates the ellipse by a given [angle] in radians. /// Rotates the ellipse by a given [angle] in radians.
void rotate(double angle) { void rotate(double angle) {
vertices.map((vector) => vector..rotate(angle)).toList(); for (final vector in vertices) {
vector.rotate(angle);
}
} }
EllipseShape copyWith({
Vector2? center,
double? majorRadius,
double? minorRadius,
}) =>
EllipseShape(
center: center ?? this.center,
majorRadius: majorRadius ?? this.majorRadius,
minorRadius: minorRadius ?? this.minorRadius,
);
} }

@ -17,6 +17,8 @@ dependencies:
ref: a50d4a1e7d9eaf66726ed1bb9894c9d495547d8f ref: a50d4a1e7d9eaf66726ed1bb9894c9d495547d8f
flutter: flutter:
sdk: flutter sdk: flutter
geometry:
path: ../geometry
dev_dependencies: dev_dependencies:
flame_test: ^1.3.0 flame_test: ^1.3.0

@ -0,0 +1,20 @@
import 'dart:math' as math;
import 'package:flame/extensions.dart';
import 'package:flame/game.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pinball_flame/pinball_flame.dart';
void main() {
group('ArcShape', () {
test('can be instantiated', () {
expect(
ArcShape(
center: Vector2.zero(),
arcRadius: 10,
angle: 2 * math.pi,
),
isA<ArcShape>(),
);
});
});
}

@ -0,0 +1,22 @@
import 'package:flame/extensions.dart';
import 'package:flame/game.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pinball_flame/pinball_flame.dart';
void main() {
group('BezierCurveShape', () {
test('can be instantiated', () {
expect(
BezierCurveShape(
controlPoints: [
Vector2(0, 0),
Vector2(10, 0),
Vector2(0, 10),
Vector2(10, 10),
],
),
isA<BezierCurveShape>(),
);
});
});
}

@ -0,0 +1,41 @@
import 'dart:math' as math;
import 'package:flame/extensions.dart';
import 'package:flame/game.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pinball_flame/pinball_flame.dart';
void main() {
group('EllipseShape', () {
test('can be instantiated', () {
expect(
EllipseShape(
center: Vector2.zero(),
majorRadius: 10,
minorRadius: 8,
),
isA<EllipseShape>(),
);
});
test('rotate returns vertices rotated', () {
const rotationAngle = 2 * math.pi;
final ellipseShape = EllipseShape(
center: Vector2.zero(),
majorRadius: 10,
minorRadius: 8,
);
final ellipseShapeRotated = EllipseShape(
center: Vector2.zero(),
majorRadius: 10,
minorRadius: 8,
)..rotate(rotationAngle);
for (var index = 0; index < ellipseShape.vertices.length; index++) {
expect(
ellipseShape.vertices[index]..rotate(rotationAngle),
equals(ellipseShapeRotated.vertices[index]),
);
}
});
});
}

@ -36,26 +36,26 @@ class _MockContact extends Mock implements Contact {}
void main() { void main() {
TestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized();
group('BumperNoiseBehavior', () {}); group('BumperNoiseBehavior', () {
late PinballAudioPlayer audioPlayer;
late PinballAudioPlayer audioPlayer; final flameTester = FlameTester(_TestGame.new);
final flameTester = FlameTester(_TestGame.new);
setUp(() {
setUp(() { audioPlayer = _MockPinballAudioPlayer();
audioPlayer = _MockPinballAudioPlayer(); });
flameTester.testGameWidget(
'plays bumper sound',
setUp: (game, _) async {
final behavior = BumperNoiseBehavior();
final parent = _TestBodyComponent();
await game.pump(parent, audioPlayer: audioPlayer);
await parent.ensureAdd(behavior);
behavior.beginContact(Object(), _MockContact());
},
verify: (_, __) async {
verify(() => audioPlayer.play(PinballAudio.bumper)).called(1);
},
);
}); });
flameTester.testGameWidget(
'plays bumper sound',
setUp: (game, _) async {
final behavior = BumperNoiseBehavior();
final parent = _TestBodyComponent();
await game.pump(parent, audioPlayer: audioPlayer);
await parent.ensureAdd(behavior);
behavior.beginContact(Object(), _MockContact());
},
verify: (_, __) async {
verify(() => audioPlayer.play(PinballAudio.bumper)).called(1);
},
);
} }

Loading…
Cancel
Save