From ed36a162d6b9655ca970360dc7770a3a5483ee69 Mon Sep 17 00:00:00 2001 From: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Date: Wed, 23 Mar 2022 03:10:08 -0500 Subject: [PATCH] refactor: dimension boundaries according to designs (#75) * refactor: correctly dimension boundaries * refactor: adjust zoom level --- lib/game/components/board.dart | 4 ++-- lib/game/components/jetpack_ramp.dart | 4 ++-- lib/game/components/launcher_ramp.dart | 22 +++++++++++++--------- lib/game/components/spaceship.dart | 4 ++-- lib/game/components/wall.dart | 8 +++++--- lib/game/pinball_game.dart | 16 ++++++++-------- 6 files changed, 32 insertions(+), 26 deletions(-) diff --git a/lib/game/components/board.dart b/lib/game/components/board.dart index 5bd4d92b..af03efdd 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.center.dx + 20, + PinballGame.boardBounds.center.dy + 48, ), ); diff --git a/lib/game/components/jetpack_ramp.dart b/lib/game/components/jetpack_ramp.dart index aa5a2d3d..4afc36d1 100644 --- a/lib/game/components/jetpack_ramp.dart +++ b/lib/game/components/jetpack_ramp.dart @@ -40,13 +40,13 @@ class JetpackRamp extends Component with HasGameRef { outsideLayer: Layer.spaceship, rotation: math.pi, ) - ..initialPosition = position - Vector2(2, 22) + ..initialPosition = position + Vector2(-2.5, -20.2) ..layer = Layer.jetpack; final rightOpening = _JetpackRampOpening( rotation: math.pi, ) - ..initialPosition = position - Vector2(-13, 22) + ..initialPosition = position + Vector2(12.9, -20.2) ..layer = Layer.opening; await addAll([ diff --git a/lib/game/components/launcher_ramp.dart b/lib/game/components/launcher_ramp.dart index 5fdabcdb..0b6e4dbf 100644 --- a/lib/game/components/launcher_ramp.dart +++ b/lib/game/components/launcher_ramp.dart @@ -26,29 +26,33 @@ class LauncherRamp extends Component with HasGameRef { RampOpeningBallContactCallback<_LauncherRampOpening>(), ); + final launcherRampRotation = + -math.atan(18.6 / PinballGame.boardBounds.height); + final straightPath = Pathway.straight( color: const Color.fromARGB(255, 34, 255, 0), - start: Vector2(position.x, position.y), - end: Vector2(position.x, 74), + start: position + Vector2(-1.2, 10), + end: position + Vector2(-1.2, 117), width: 5, + rotation: launcherRampRotation, ) ..initialPosition = position ..layer = layer; final curvedPath = Pathway.arc( color: const Color.fromARGB(255, 251, 255, 0), - center: position + Vector2(-1, 68), - radius: 20, - angle: 8 * math.pi / 9, + center: position + Vector2(-2.8, 87.2), + radius: 16.3, + angle: math.pi / 2, width: 5, - rotation: math.pi, + rotation: 3 * math.pi / 2, )..layer = layer; - final leftOpening = _LauncherRampOpening(rotation: 13 * math.pi / 180) - ..initialPosition = position + Vector2(1, 49) + final leftOpening = _LauncherRampOpening(rotation: math.pi / 2) + ..initialPosition = position + Vector2(-11.8, 66.3) ..layer = Layer.opening; final rightOpening = _LauncherRampOpening(rotation: 0) - ..initialPosition = position + Vector2(-16, 46) + ..initialPosition = position + Vector2(-4.9, 59.4) ..layer = Layer.opening; await addAll([ diff --git a/lib/game/components/spaceship.dart b/lib/game/components/spaceship.dart index 51dbc291..8243a974 100644 --- a/lib/game/components/spaceship.dart +++ b/lib/game/components/spaceship.dart @@ -17,8 +17,8 @@ class Spaceship extends Forge2DBlueprint { @override void build() { final position = Vector2( - PinballGame.boardBounds.left + radius + 0.5, - PinballGame.boardBounds.center.dy + 34, + PinballGame.boardBounds.left + radius + 15, + PinballGame.boardBounds.center.dy + 30, ); addAllContactCallback([ diff --git a/lib/game/components/wall.dart b/lib/game/components/wall.dart index 62f9033f..7475715e 100644 --- a/lib/game/components/wall.dart +++ b/lib/game/components/wall.dart @@ -41,11 +41,13 @@ class Wall extends BodyComponent { /// Create top, left, and right [Wall]s for the game board. List createBoundaries(Forge2DGame game) { - final topLeft = PinballGame.boardBounds.topLeft.toVector2(); + final topLeft = + PinballGame.boardBounds.topLeft.toVector2() + Vector2(18.6, 0); final bottomRight = PinballGame.boardBounds.bottomRight.toVector2(); - final topRight = Vector2(bottomRight.x, topLeft.y); - final bottomLeft = Vector2(topLeft.x, bottomRight.y); + final topRight = + PinballGame.boardBounds.topRight.toVector2() - Vector2(18.6, 0); + final bottomLeft = PinballGame.boardBounds.bottomLeft.toVector2(); return [ Wall(start: topLeft, end: topRight), diff --git a/lib/game/pinball_game.dart b/lib/game/pinball_game.dart index d1abb70e..44a7ec01 100644 --- a/lib/game/pinball_game.dart +++ b/lib/game/pinball_game.dart @@ -19,7 +19,7 @@ class PinballGame extends Forge2DGame late final Plunger plunger; - static final boardSize = Vector2(72, 128); + static final boardSize = Vector2(101.6, 143.8); static final boardBounds = Rect.fromCenter( center: Offset.zero, width: boardSize.x, @@ -46,7 +46,7 @@ class PinballGame extends Forge2DGame // Fix camera on the center of the board. camera ..followVector2(Vector2.zero()) - ..zoom = size.y / 14; + ..zoom = size.y / 16; } void _addContactCallbacks() { @@ -63,10 +63,10 @@ class PinballGame extends Forge2DGame Future _addPlunger() async { plunger = Plunger(compressionDistance: 2); - plunger.initialPosition = boardBounds.bottomRight.toVector2() - + plunger.initialPosition = boardBounds.bottomRight.toVector2() + Vector2( - 8, - -10, + -5, + 10, ); await add(plunger); } @@ -85,13 +85,13 @@ class PinballGame extends Forge2DGame Future _addPaths() async { final jetpackRamp = JetpackRamp( position: Vector2( - PinballGame.boardBounds.left + 25, - PinballGame.boardBounds.top - 20, + PinballGame.boardBounds.left + 40.5, + PinballGame.boardBounds.top - 31.5, ), ); final launcherRamp = LauncherRamp( position: Vector2( - PinballGame.boardBounds.right - 23, + PinballGame.boardBounds.right - 30, PinballGame.boardBounds.bottom + 40, ), );