diff --git a/assets/images/components/sauce.png b/assets/images/components/sauce.png deleted file mode 100644 index 743a920a..00000000 Binary files a/assets/images/components/sauce.png and /dev/null differ diff --git a/lib/game/components/baseboard.dart b/lib/game/components/baseboard.dart index 60d0ebe7..d9dc3512 100644 --- a/lib/game/components/baseboard.dart +++ b/lib/game/components/baseboard.dart @@ -5,7 +5,7 @@ import 'package:pinball/game/game.dart'; import 'package:pinball_components/pinball_components.dart'; /// {@template baseboard} -/// Straight, angled board piece to corral the [Ball] towards the [Flipper]s. +/// Wing-shaped board piece to corral the [Ball] towards the [Flipper]s. /// {@endtemplate} class Baseboard extends BodyComponent with InitialPosition { /// {@macro baseboard} @@ -13,41 +13,68 @@ class Baseboard extends BodyComponent with InitialPosition { required BoardSide side, }) : _side = side; - /// The width of the [Baseboard]. - static const width = 10.0; - - /// The height of the [Baseboard]. - static const height = 2.0; + /// The size of the [Baseboard]. + static final size = Vector2(24.2, 13.5); /// Whether the [Baseboard] is on the left or right side of the board. final BoardSide _side; List _createFixtureDefs() { final fixturesDef = []; + final direction = _side.direction; + final arcsAngle = -1.11 * direction; + const arcsRotation = math.pi / 2.08; + + final topCircleShape = CircleShape()..radius = 0.7; + topCircleShape.position.setValues(11.39 * direction, 6.05); + final topCircleFixtureDef = FixtureDef(topCircleShape); + fixturesDef.add(topCircleFixtureDef); + + final innerEdgeShape = EdgeShape() + ..set( + Vector2(10.86 * direction, 6.45), + Vector2(6.96 * direction, 0.25), + ); + final innerEdgeShapeFixtureDef = FixtureDef(innerEdgeShape); + fixturesDef.add(innerEdgeShapeFixtureDef); + + final outerEdgeShape = EdgeShape() + ..set( + Vector2(11.96 * direction, 5.85), + Vector2(5.48 * direction, -4.85), + ); + final outerEdgeShapeFixtureDef = FixtureDef(outerEdgeShape); + fixturesDef.add(outerEdgeShapeFixtureDef); + + final upperArcFixtureDefs = Pathway.arc( + center: Vector2(1.76 * direction, 3.25), + width: 0, + radius: 6.1, + angle: arcsAngle, + rotation: arcsRotation, + singleWall: true, + ).createFixtureDefs(); + fixturesDef.addAll(upperArcFixtureDefs); + + final lowerArcFixtureDefs = Pathway.arc( + center: Vector2(1.85 * direction, -2.15), + width: 0, + radius: 4.5, + angle: arcsAngle, + rotation: arcsRotation, + singleWall: true, + ).createFixtureDefs(); + fixturesDef.addAll(lowerArcFixtureDefs); - final circleShape1 = CircleShape()..radius = Baseboard.height / 2; - circleShape1.position.setValues( - -(Baseboard.width / 2) + circleShape1.radius, - 0, - ); - final circle1FixtureDef = FixtureDef(circleShape1); - fixturesDef.add(circle1FixtureDef); - - final circleShape2 = CircleShape()..radius = Baseboard.height / 2; - circleShape2.position.setValues( - (Baseboard.width / 2) - circleShape2.radius, - 0, - ); - final circle2FixtureDef = FixtureDef(circleShape2); - fixturesDef.add(circle2FixtureDef); - - final rectangle = PolygonShape() - ..setAsBoxXY( - (Baseboard.width - Baseboard.height) / 2, - Baseboard.height / 2, + final bottomRectangle = PolygonShape() + ..setAsBox( + 7, + 2, + Vector2(-5.14 * direction, -4.75), + 0, ); - final rectangleFixtureDef = FixtureDef(rectangle); - fixturesDef.add(rectangleFixtureDef); + final bottomRectangleFixtureDef = FixtureDef(bottomRectangle); + fixturesDef.add(bottomRectangleFixtureDef); return fixturesDef; } @@ -56,7 +83,7 @@ class Baseboard extends BodyComponent with InitialPosition { Body createBody() { // TODO(allisonryan0002): share sweeping angle with flipper when components // are grouped. - const angle = math.pi / 7; + const angle = math.pi / 5; final bodyDef = BodyDef() ..position = initialPosition diff --git a/lib/game/components/board.dart b/lib/game/components/board.dart index 6e895d6e..adfbef49 100644 --- a/lib/game/components/board.dart +++ b/lib/game/components/board.dart @@ -134,8 +134,8 @@ class _BottomGroupSide extends Component { final baseboard = Baseboard(side: _side) ..initialPosition = _position + Vector2( - (Flipper.size.x * direction) - direction, - Flipper.size.y, + (Baseboard.size.x / 1.6 * direction), + Baseboard.size.y - 2, ); final kicker = Kicker( side: _side, diff --git a/lib/gen/assets.gen.dart b/lib/gen/assets.gen.dart index ba75412b..6e81fe77 100644 --- a/lib/gen/assets.gen.dart +++ b/lib/gen/assets.gen.dart @@ -17,8 +17,6 @@ class $AssetsImagesComponentsGen { AssetGenImage get flipper => const AssetGenImage('assets/images/components/flipper.png'); - AssetGenImage get sauce => - const AssetGenImage('assets/images/components/sauce.png'); $AssetsImagesComponentsSpaceshipGen get spaceship => const $AssetsImagesComponentsSpaceshipGen(); } diff --git a/test/game/components/baseboard_test.dart b/test/game/components/baseboard_test.dart index 75cc62cc..f834a41e 100644 --- a/test/game/components/baseboard_test.dart +++ b/test/game/components/baseboard_test.dart @@ -61,14 +61,14 @@ void main() { group('fixtures', () { flameTester.test( - 'has three', + 'has six', (game) async { final baseboard = Baseboard( side: BoardSide.left, ); await game.ensureAdd(baseboard); - expect(baseboard.body.fixtures.length, equals(3)); + expect(baseboard.body.fixtures.length, equals(6)); }, ); });