|
|
@ -10,18 +10,17 @@ class SpaceshipDropRamp extends Forge2DBlueprint {
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void build() {
|
|
|
|
void build() {
|
|
|
|
final position = Vector2(
|
|
|
|
final position = Vector2(
|
|
|
|
PinballGame.boardBounds.left + 23,
|
|
|
|
PinballGame.boardBounds.left + 22,
|
|
|
|
PinballGame.boardBounds.center.dy + 25,
|
|
|
|
PinballGame.boardBounds.center.dy + 27,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
addAllContactCallback([
|
|
|
|
addAllContactCallback([
|
|
|
|
SpaceshipHoleBallContactCallback(),
|
|
|
|
SpaceshipDropHoleBallContactCallback(),
|
|
|
|
SpaceshipEntranceBallContactCallback(),
|
|
|
|
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
final curvedPath = Pathway.bezierCurve(
|
|
|
|
final curvedPath = Pathway.bezierCurve(
|
|
|
|
color: Color.fromARGB(255, 226, 226, 218),
|
|
|
|
color: const Color.fromARGB(255, 226, 226, 218),
|
|
|
|
width: 5,
|
|
|
|
width: 4,
|
|
|
|
rotation: 230 * math.pi / 180,
|
|
|
|
rotation: 230 * math.pi / 180,
|
|
|
|
controlPoints: [
|
|
|
|
controlPoints: [
|
|
|
|
Vector2(0, 0),
|
|
|
|
Vector2(0, 0),
|
|
|
@ -31,42 +30,67 @@ class SpaceshipDropRamp extends Forge2DBlueprint {
|
|
|
|
],
|
|
|
|
],
|
|
|
|
)..layer = Layer.spaceship_drop;
|
|
|
|
)..layer = Layer.spaceship_drop;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final curvedEntrance = Pathway.arc(
|
|
|
|
|
|
|
|
color: const Color.fromARGB(255, 226, 226, 218),
|
|
|
|
|
|
|
|
center: position,
|
|
|
|
|
|
|
|
radius: 4,
|
|
|
|
|
|
|
|
angle: math.pi / 2,
|
|
|
|
|
|
|
|
width: 5,
|
|
|
|
|
|
|
|
rotation: 218 * math.pi / 180,
|
|
|
|
|
|
|
|
singleWall: true,
|
|
|
|
|
|
|
|
)..layer = Layer.spaceship_drop;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final curvedExit = Pathway.arc(
|
|
|
|
|
|
|
|
color: const Color.fromARGB(255, 226, 226, 218),
|
|
|
|
|
|
|
|
center: position,
|
|
|
|
|
|
|
|
radius: 4,
|
|
|
|
|
|
|
|
angle: math.pi / 2,
|
|
|
|
|
|
|
|
width: 5,
|
|
|
|
|
|
|
|
rotation: 36 * math.pi / 180,
|
|
|
|
|
|
|
|
singleWall: true,
|
|
|
|
|
|
|
|
)..layer = Layer.spaceship_drop;
|
|
|
|
|
|
|
|
|
|
|
|
addAll([
|
|
|
|
addAll([
|
|
|
|
curvedPath..initialPosition = position,
|
|
|
|
curvedPath..initialPosition = position,
|
|
|
|
|
|
|
|
curvedEntrance..initialPosition = position + Vector2(26.5, -30),
|
|
|
|
|
|
|
|
curvedExit..initialPosition = position + Vector2(29, -66.5),
|
|
|
|
|
|
|
|
SpaceshipDropHole()..initialPosition = position + Vector2(0, -42),
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class SpaceshipRampEntrance extends RampOpening {
|
|
|
|
/// {@template spaceship_drop_hole}
|
|
|
|
/// {@macro spaceship_ramp_entrance}
|
|
|
|
/// A sensor [BodyComponent] responsible for sending the [Ball]
|
|
|
|
SpaceshipRampEntrance()
|
|
|
|
/// back to the board.
|
|
|
|
|
|
|
|
/// {@endtemplate}
|
|
|
|
|
|
|
|
class SpaceshipDropHole extends RampOpening {
|
|
|
|
|
|
|
|
/// {@macro spaceship_drop_hole}
|
|
|
|
|
|
|
|
SpaceshipDropHole()
|
|
|
|
: super(
|
|
|
|
: super(
|
|
|
|
pathwayLayer: Layer.spaceship_drop,
|
|
|
|
pathwayLayer: Layer.spaceship_drop,
|
|
|
|
orientation: RampOrientation.up,
|
|
|
|
orientation: RampOrientation.down,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
layer = Layer.spaceship_drop;
|
|
|
|
layer = Layer.spaceship_drop;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Shape get shape {
|
|
|
|
Shape get shape {
|
|
|
|
const radius = Spaceship.radius * 2;
|
|
|
|
return CircleShape()..radius = Spaceship.radius / 40;
|
|
|
|
return PolygonShape();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class SpaceshipRampExit extends RampOpening {
|
|
|
|
/// [ContactCallback] that handles the contact between the [Ball]
|
|
|
|
/// {@macro spaceship_ramp_entrance}
|
|
|
|
/// and a [SpaceshipDropHole].
|
|
|
|
SpaceshipRampExit()
|
|
|
|
///
|
|
|
|
: super(
|
|
|
|
/// It resets the [Ball] priority and filter data so it will "be back" on the
|
|
|
|
pathwayLayer: Layer.spaceship_drop,
|
|
|
|
/// board.
|
|
|
|
orientation: RampOrientation.down,
|
|
|
|
class SpaceshipDropHoleBallContactCallback
|
|
|
|
) {
|
|
|
|
extends ContactCallback<SpaceshipDropHole, Ball> {
|
|
|
|
layer = Layer.spaceship_drop;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Shape get shape {
|
|
|
|
void begin(SpaceshipDropHole hole, Ball ball, _) {
|
|
|
|
const radius = Spaceship.radius * 2;
|
|
|
|
ball
|
|
|
|
return PolygonShape();
|
|
|
|
..priority = 1
|
|
|
|
|
|
|
|
..gameRef.reorderChildren()
|
|
|
|
|
|
|
|
..layer = hole.outsideLayer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|