|
|
@ -5,7 +5,7 @@ import 'package:pinball/game/game.dart';
|
|
|
|
import 'package:pinball_components/pinball_components.dart';
|
|
|
|
import 'package:pinball_components/pinball_components.dart';
|
|
|
|
|
|
|
|
|
|
|
|
/// {@template baseboard}
|
|
|
|
/// {@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}
|
|
|
|
/// {@endtemplate}
|
|
|
|
class Baseboard extends BodyComponent with InitialPosition {
|
|
|
|
class Baseboard extends BodyComponent with InitialPosition {
|
|
|
|
/// {@macro baseboard}
|
|
|
|
/// {@macro baseboard}
|
|
|
@ -13,41 +13,68 @@ class Baseboard extends BodyComponent with InitialPosition {
|
|
|
|
required BoardSide side,
|
|
|
|
required BoardSide side,
|
|
|
|
}) : _side = side;
|
|
|
|
}) : _side = side;
|
|
|
|
|
|
|
|
|
|
|
|
/// The width of the [Baseboard].
|
|
|
|
/// The size of the [Baseboard].
|
|
|
|
static const width = 10.0;
|
|
|
|
static final size = Vector2(24.2, 13.5);
|
|
|
|
|
|
|
|
|
|
|
|
/// The height of the [Baseboard].
|
|
|
|
|
|
|
|
static const height = 2.0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Whether the [Baseboard] is on the left or right side of the board.
|
|
|
|
/// Whether the [Baseboard] is on the left or right side of the board.
|
|
|
|
final BoardSide _side;
|
|
|
|
final BoardSide _side;
|
|
|
|
|
|
|
|
|
|
|
|
List<FixtureDef> _createFixtureDefs() {
|
|
|
|
List<FixtureDef> _createFixtureDefs() {
|
|
|
|
final fixturesDef = <FixtureDef>[];
|
|
|
|
final fixturesDef = <FixtureDef>[];
|
|
|
|
|
|
|
|
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;
|
|
|
|
final bottomRectangle = PolygonShape()
|
|
|
|
circleShape1.position.setValues(
|
|
|
|
..setAsBox(
|
|
|
|
-(Baseboard.width / 2) + circleShape1.radius,
|
|
|
|
7,
|
|
|
|
0,
|
|
|
|
2,
|
|
|
|
);
|
|
|
|
Vector2(-5.14 * direction, -4.75),
|
|
|
|
final circle1FixtureDef = FixtureDef(circleShape1);
|
|
|
|
0,
|
|
|
|
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 rectangleFixtureDef = FixtureDef(rectangle);
|
|
|
|
final bottomRectangleFixtureDef = FixtureDef(bottomRectangle);
|
|
|
|
fixturesDef.add(rectangleFixtureDef);
|
|
|
|
fixturesDef.add(bottomRectangleFixtureDef);
|
|
|
|
|
|
|
|
|
|
|
|
return fixturesDef;
|
|
|
|
return fixturesDef;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -56,7 +83,7 @@ class Baseboard extends BodyComponent with InitialPosition {
|
|
|
|
Body createBody() {
|
|
|
|
Body createBody() {
|
|
|
|
// TODO(allisonryan0002): share sweeping angle with flipper when components
|
|
|
|
// TODO(allisonryan0002): share sweeping angle with flipper when components
|
|
|
|
// are grouped.
|
|
|
|
// are grouped.
|
|
|
|
const angle = math.pi / 7;
|
|
|
|
const angle = math.pi / 5;
|
|
|
|
|
|
|
|
|
|
|
|
final bodyDef = BodyDef()
|
|
|
|
final bodyDef = BodyDef()
|
|
|
|
..position = initialPosition
|
|
|
|
..position = initialPosition
|
|
|
|