diff --git a/lib/game/components/board.dart b/lib/game/components/board.dart index 2e2f5a9c..3bba3b74 100644 --- a/lib/game/components/board.dart +++ b/lib/game/components/board.dart @@ -22,8 +22,8 @@ class Board extends Component { final dashForest = _FlutterForest( position: Vector2( - PinballGame.boardBounds.right - 20, - PinballGame.boardBounds.top - 20, + PinballGame.boardBounds.right - 20, + PinballGame.boardBounds.top - 20, ), ); diff --git a/lib/game/components/jetpack_ramp.dart b/lib/game/components/jetpack_ramp.dart index df9db615..aa5a2d3d 100644 --- a/lib/game/components/jetpack_ramp.dart +++ b/lib/game/components/jetpack_ramp.dart @@ -30,20 +30,23 @@ class JetpackRamp extends Component with HasGameRef { // TODO(ruialonso): Use a bezier curve once control points are defined. color: const Color.fromARGB(255, 8, 218, 241), center: position, - width: 20, - radius: 60, + width: 5, + radius: 18, angle: math.pi, - ) - ..initialPosition = position + Vector2(60, 0) - ..layer = layer; + rotation: math.pi, + )..layer = layer; - // TODO figure out the new values for this - final leftOpening = _JetpackRampOpening(outsideLayer: Layer.spaceship) - ..initialPosition = position + Vector2(-27.6, 25.3) + final leftOpening = _JetpackRampOpening( + outsideLayer: Layer.spaceship, + rotation: math.pi, + ) + ..initialPosition = position - Vector2(2, 22) ..layer = Layer.jetpack; - final rightOpening = _JetpackRampOpening() - ..initialPosition = position + Vector2(-10.6, 25.3) + final rightOpening = _JetpackRampOpening( + rotation: math.pi, + ) + ..initialPosition = position - Vector2(-13, 22) ..layer = Layer.opening; await addAll([ @@ -62,20 +65,26 @@ class _JetpackRampOpening extends RampOpening { /// {@macro jetpack_ramp_opening} _JetpackRampOpening({ Layer? outsideLayer, - }) : super( + required double rotation, + }) : _rotation = rotation, + super( pathwayLayer: Layer.jetpack, outsideLayer: outsideLayer, orientation: RampOrientation.down, ); - // TODO(ruialonso): Avoid magic number 2, should be proportional to + final double _rotation; + + // TODO(ruialonso): Avoid magic number 3, should be propotional to // [JetpackRamp]. - static const _size = 2; + static final Vector2 _size = Vector2(3, .1); @override Shape get shape => PolygonShape() - ..setAsEdge( - Vector2(initialPosition.x - _size, initialPosition.y), - Vector2(initialPosition.x + _size, initialPosition.y), + ..setAsBox( + _size.x, + _size.y, + initialPosition, + _rotation, ); } diff --git a/lib/game/components/launcher_ramp.dart b/lib/game/components/launcher_ramp.dart index 6d585af1..5fdabcdb 100644 --- a/lib/game/components/launcher_ramp.dart +++ b/lib/game/components/launcher_ramp.dart @@ -29,27 +29,26 @@ class LauncherRamp extends Component with HasGameRef { final straightPath = Pathway.straight( color: const Color.fromARGB(255, 34, 255, 0), start: Vector2(position.x, position.y), - end: Vector2(position.x, 620), - width: 25, + end: Vector2(position.x, 74), + width: 5, ) ..initialPosition = position ..layer = layer; + final curvedPath = Pathway.arc( color: const Color.fromARGB(255, 251, 255, 0), - center: position + Vector2(116, -20), - radius: 80, - angle: 10 * math.pi / 12, - width: 25, - ) - ..initialPosition = position + Vector2(-28.8, -6) - ..layer = layer; + center: position + Vector2(-1, 68), + radius: 20, + angle: 8 * math.pi / 9, + width: 5, + rotation: math.pi, + )..layer = layer; - // TODO figure the new values for the openings final leftOpening = _LauncherRampOpening(rotation: 13 * math.pi / 180) - ..initialPosition = position + Vector2(-72.5, 12) + ..initialPosition = position + Vector2(1, 49) ..layer = Layer.opening; final rightOpening = _LauncherRampOpening(rotation: 0) - ..initialPosition = position + Vector2(-46.8, 17) + ..initialPosition = position + Vector2(-16, 46) ..layer = Layer.opening; await addAll([ diff --git a/lib/game/components/pathway.dart b/lib/game/components/pathway.dart index 414442d3..9ec983cd 100644 --- a/lib/game/components/pathway.dart +++ b/lib/game/components/pathway.dart @@ -152,7 +152,7 @@ class Pathway extends BodyComponent with InitialPosition, Layered { for (final path in _paths) { final chain = ChainShape() ..createChain( - path.map(gameRef.screenToWorld).toList(), + path.toList(), ); fixturesDef.add(FixtureDef(chain)); } diff --git a/lib/game/components/spaceship.dart b/lib/game/components/spaceship.dart index da66c479..d933a79f 100644 --- a/lib/game/components/spaceship.dart +++ b/lib/game/components/spaceship.dart @@ -16,8 +16,8 @@ class Spaceship extends Forge2DBlueprint { @override void build() { final position = Vector2( - PinballGame.boardBounds.left + radius + 4, - PinballGame.boardBounds.center.dy + 5, + PinballGame.boardBounds.left + radius + 0.5, + PinballGame.boardBounds.center.dy + 34, ); addAllContactCallback([ diff --git a/lib/game/pinball_game.dart b/lib/game/pinball_game.dart index fc498cec..c23fa095 100644 --- a/lib/game/pinball_game.dart +++ b/lib/game/pinball_game.dart @@ -83,14 +83,14 @@ class PinballGame extends Forge2DGame Future _addPaths() async { final jetpackRamp = JetpackRamp( position: Vector2( - boardBounds.left - 14, - boardBounds.top - 10, + PinballGame.boardBounds.left + 25, + PinballGame.boardBounds.top - 20, ), ); final launcherRamp = LauncherRamp( position: Vector2( - boardBounds.right - 14, - boardBounds.top - 10, + PinballGame.boardBounds.right - 23, + PinballGame.boardBounds.bottom + 40, ), ); diff --git a/test/game/components/board_test.dart b/test/game/components/board_test.dart index ccf599ec..d1057b47 100644 --- a/test/game/components/board_test.dart +++ b/test/game/components/board_test.dart @@ -15,7 +15,7 @@ void main() { flameTester.test( 'loads correctly', (game) async { - final board = Board(size: Vector2.all(500)); + final board = Board(); await game.ready(); await game.ensureAdd(board); @@ -27,7 +27,7 @@ void main() { flameTester.test( 'has one left flipper', (game) async { - final board = Board(size: Vector2.all(500)); + final board = Board(); await game.ready(); await game.ensureAdd(board); @@ -41,7 +41,7 @@ void main() { flameTester.test( 'has one right flipper', (game) async { - final board = Board(size: Vector2.all(500)); + final board = Board(); await game.ready(); await game.ensureAdd(board); @@ -55,7 +55,7 @@ void main() { flameTester.test( 'has two Baseboards', (game) async { - final board = Board(size: Vector2.all(500)); + final board = Board(); await game.ready(); await game.ensureAdd(board); @@ -67,7 +67,7 @@ void main() { flameTester.test( 'has two SlingShots', (game) async { - final board = Board(size: Vector2.all(500)); + final board = Board(); await game.ready(); await game.ensureAdd(board); @@ -80,7 +80,7 @@ void main() { 'has three RoundBumpers', (game) async { // TODO(alestiago): change to [NestBumpers] once provided. - final board = Board(size: Vector2.all(500)); + final board = Board(); await game.ready(); await game.ensureAdd(board);