diff --git a/lib/game/components/jetpack_ramp.dart b/lib/game/components/jetpack_ramp.dart index a11ac40c..3820d561 100644 --- a/lib/game/components/jetpack_ramp.dart +++ b/lib/game/components/jetpack_ramp.dart @@ -30,22 +30,21 @@ 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: 80, + width: 62, radius: 200, - angle: 7 * math.pi / 6, - rotation: -math.pi / 18, + angle: math.pi, ) ..initialPosition = position ..layer = layer; final leftOpening = _JetpackRampOpening( - rotation: 15 * math.pi / 180, + rotation: 0, + outsideLayer: Layer.spaceship, ) - ..initialPosition = position + Vector2(-27, 21) - ..layer = Layer.opening; - final rightOpening = _JetpackRampOpening( - rotation: -math.pi / 20, - ) - ..initialPosition = position + Vector2(-11.2, 22.5) + ..initialPosition = position + Vector2(-27.6, 25.3) + ..layer = Layer.jetpack; + + final rightOpening = _JetpackRampOpening(rotation: 0) + ..initialPosition = position + Vector2(-10.6, 25.3) ..layer = Layer.opening; await addAll([ @@ -64,24 +63,24 @@ class _JetpackRampOpening extends RampOpening { /// {@macro jetpack_ramp_opening} _JetpackRampOpening({ required double rotation, + Layer? outsideLayer, }) : _rotation = rotation, super( pathwayLayer: Layer.jetpack, + outsideLayer: outsideLayer, orientation: RampOrientation.down, ); final double _rotation; - // TODO(ruialonso): Avoid magic number 3, should be propotional to + // TODO(ruialonso): Avoid magic number 2, should be proportional to // [JetpackRamp]. - static final Vector2 _size = Vector2(3, .1); + static const _size = 2; @override Shape get shape => PolygonShape() - ..setAsBox( - _size.x, - _size.y, - initialPosition, - _rotation, + ..setAsEdge( + Vector2(initialPosition.x - _size, initialPosition.y), + Vector2(initialPosition.x + _size, initialPosition.y), ); } diff --git a/lib/game/pinball_game.dart b/lib/game/pinball_game.dart index ef5cb3b1..86bceef6 100644 --- a/lib/game/pinball_game.dart +++ b/lib/game/pinball_game.dart @@ -27,33 +27,22 @@ class PinballGame extends Forge2DGame _addContactCallbacks(); await _addGameBoundaries(); + unawaited(_addBoard()); unawaited(_addPlunger()); + unawaited(_addBonusWord()); unawaited(_addPaths()); - unawaited(addFromBlueprint(Spaceship())); + } - // Corner wall above plunger so the ball deflects into the rest of the - // board. - // TODO(allisonryan0002): remove once we have the launch track for the ball. - await add( - Wall( - start: screenToWorld( - Vector2( - camera.viewport.effectiveSize.x, - 100, - ), - ), - end: screenToWorld( - Vector2( - camera.viewport.effectiveSize.x - 100, - 0, - ), - ), - ), - ); + void _addContactCallbacks() { + addContactCallback(BallScorePointsCallback()); + addContactCallback(BottomWallBallContactCallback()); + addContactCallback(BonusLetterBallContactCallback()); + } - unawaited(_addBonusWord()); - unawaited(_addBoard()); + Future _addGameBoundaries() async { + await add(BottomWall(this)); + createBoundaries(this).forEach(add); } Future _addBoard() async { @@ -68,6 +57,20 @@ class PinballGame extends Forge2DGame await add(board); } + Future _addPlunger() async { + plunger = Plunger( + compressionDistance: camera.viewport.effectiveSize.y / 12, + ); + plunger.initialPosition = screenToWorld( + Vector2( + camera.viewport.effectiveSize.x / 2 + 450, + camera.viewport.effectiveSize.y - plunger.compressionDistance, + ), + ); + + await add(plunger); + } + Future _addBonusWord() async { await add( BonusWord( @@ -81,33 +84,9 @@ class PinballGame extends Forge2DGame ); } - void spawnBall() { - final ball = Ball(); - add( - ball - ..initialPosition = plunger.body.position + Vector2(0, ball.size.y / 2), - ); - } - - void _addContactCallbacks() { - addContactCallback(BallScorePointsCallback()); - addContactCallback(BottomWallBallContactCallback()); - addContactCallback(BonusLetterBallContactCallback()); - } - - Future _addGameBoundaries() async { - await add(BottomWall(this)); - createBoundaries(this).forEach(add); - } - Future _addPaths() async { final jetpackRamp = JetpackRamp( - position: screenToWorld( - Vector2( - camera.viewport.effectiveSize.x / 2 - 150, - camera.viewport.effectiveSize.y / 2 - 250, - ), - ), + position: Vector2(42.6, -45), ); final launcherRamp = LauncherRamp( position: screenToWorld( @@ -121,18 +100,12 @@ class PinballGame extends Forge2DGame await addAll([jetpackRamp, launcherRamp]); } - Future _addPlunger() async { - plunger = Plunger( - compressionDistance: camera.viewport.effectiveSize.y / 12, - ); - plunger.initialPosition = screenToWorld( - Vector2( - camera.viewport.effectiveSize.x / 2 + 450, - camera.viewport.effectiveSize.y - plunger.compressionDistance, - ), + void spawnBall() { + final ball = Ball(); + add( + ball + ..initialPosition = plunger.body.position + Vector2(0, ball.size.y / 2), ); - - await add(plunger); } }