refactor: dimension boundaries according to designs (#75)

* refactor: correctly dimension boundaries

* refactor: adjust zoom level
pull/77/head
Allison Ryan 3 years ago committed by GitHub
parent c03cf6b2a2
commit ed36a162d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -22,8 +22,8 @@ class Board extends Component {
final dashForest = _FlutterForest( final dashForest = _FlutterForest(
position: Vector2( position: Vector2(
PinballGame.boardBounds.right - 20, PinballGame.boardBounds.center.dx + 20,
PinballGame.boardBounds.top - 20, PinballGame.boardBounds.center.dy + 48,
), ),
); );

@ -40,13 +40,13 @@ class JetpackRamp extends Component with HasGameRef<PinballGame> {
outsideLayer: Layer.spaceship, outsideLayer: Layer.spaceship,
rotation: math.pi, rotation: math.pi,
) )
..initialPosition = position - Vector2(2, 22) ..initialPosition = position + Vector2(-2.5, -20.2)
..layer = Layer.jetpack; ..layer = Layer.jetpack;
final rightOpening = _JetpackRampOpening( final rightOpening = _JetpackRampOpening(
rotation: math.pi, rotation: math.pi,
) )
..initialPosition = position - Vector2(-13, 22) ..initialPosition = position + Vector2(12.9, -20.2)
..layer = Layer.opening; ..layer = Layer.opening;
await addAll([ await addAll([

@ -26,29 +26,33 @@ class LauncherRamp extends Component with HasGameRef<PinballGame> {
RampOpeningBallContactCallback<_LauncherRampOpening>(), RampOpeningBallContactCallback<_LauncherRampOpening>(),
); );
final launcherRampRotation =
-math.atan(18.6 / PinballGame.boardBounds.height);
final straightPath = Pathway.straight( final straightPath = Pathway.straight(
color: const Color.fromARGB(255, 34, 255, 0), color: const Color.fromARGB(255, 34, 255, 0),
start: Vector2(position.x, position.y), start: position + Vector2(-1.2, 10),
end: Vector2(position.x, 74), end: position + Vector2(-1.2, 117),
width: 5, width: 5,
rotation: launcherRampRotation,
) )
..initialPosition = position ..initialPosition = position
..layer = layer; ..layer = layer;
final curvedPath = Pathway.arc( final curvedPath = Pathway.arc(
color: const Color.fromARGB(255, 251, 255, 0), color: const Color.fromARGB(255, 251, 255, 0),
center: position + Vector2(-1, 68), center: position + Vector2(-2.8, 87.2),
radius: 20, radius: 16.3,
angle: 8 * math.pi / 9, angle: math.pi / 2,
width: 5, width: 5,
rotation: math.pi, rotation: 3 * math.pi / 2,
)..layer = layer; )..layer = layer;
final leftOpening = _LauncherRampOpening(rotation: 13 * math.pi / 180) final leftOpening = _LauncherRampOpening(rotation: math.pi / 2)
..initialPosition = position + Vector2(1, 49) ..initialPosition = position + Vector2(-11.8, 66.3)
..layer = Layer.opening; ..layer = Layer.opening;
final rightOpening = _LauncherRampOpening(rotation: 0) final rightOpening = _LauncherRampOpening(rotation: 0)
..initialPosition = position + Vector2(-16, 46) ..initialPosition = position + Vector2(-4.9, 59.4)
..layer = Layer.opening; ..layer = Layer.opening;
await addAll([ await addAll([

@ -17,8 +17,8 @@ class Spaceship extends Forge2DBlueprint {
@override @override
void build() { void build() {
final position = Vector2( final position = Vector2(
PinballGame.boardBounds.left + radius + 0.5, PinballGame.boardBounds.left + radius + 15,
PinballGame.boardBounds.center.dy + 34, PinballGame.boardBounds.center.dy + 30,
); );
addAllContactCallback([ addAllContactCallback([

@ -41,11 +41,13 @@ class Wall extends BodyComponent {
/// Create top, left, and right [Wall]s for the game board. /// Create top, left, and right [Wall]s for the game board.
List<Wall> createBoundaries(Forge2DGame game) { List<Wall> 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 bottomRight = PinballGame.boardBounds.bottomRight.toVector2();
final topRight = Vector2(bottomRight.x, topLeft.y); final topRight =
final bottomLeft = Vector2(topLeft.x, bottomRight.y); PinballGame.boardBounds.topRight.toVector2() - Vector2(18.6, 0);
final bottomLeft = PinballGame.boardBounds.bottomLeft.toVector2();
return [ return [
Wall(start: topLeft, end: topRight), Wall(start: topLeft, end: topRight),

@ -19,7 +19,7 @@ class PinballGame extends Forge2DGame
late final Plunger plunger; late final Plunger plunger;
static final boardSize = Vector2(72, 128); static final boardSize = Vector2(101.6, 143.8);
static final boardBounds = Rect.fromCenter( static final boardBounds = Rect.fromCenter(
center: Offset.zero, center: Offset.zero,
width: boardSize.x, width: boardSize.x,
@ -46,7 +46,7 @@ class PinballGame extends Forge2DGame
// Fix camera on the center of the board. // Fix camera on the center of the board.
camera camera
..followVector2(Vector2.zero()) ..followVector2(Vector2.zero())
..zoom = size.y / 14; ..zoom = size.y / 16;
} }
void _addContactCallbacks() { void _addContactCallbacks() {
@ -63,10 +63,10 @@ class PinballGame extends Forge2DGame
Future<void> _addPlunger() async { Future<void> _addPlunger() async {
plunger = Plunger(compressionDistance: 2); plunger = Plunger(compressionDistance: 2);
plunger.initialPosition = boardBounds.bottomRight.toVector2() - plunger.initialPosition = boardBounds.bottomRight.toVector2() +
Vector2( Vector2(
8, -5,
-10, 10,
); );
await add(plunger); await add(plunger);
} }
@ -85,13 +85,13 @@ class PinballGame extends Forge2DGame
Future<void> _addPaths() async { Future<void> _addPaths() async {
final jetpackRamp = JetpackRamp( final jetpackRamp = JetpackRamp(
position: Vector2( position: Vector2(
PinballGame.boardBounds.left + 25, PinballGame.boardBounds.left + 40.5,
PinballGame.boardBounds.top - 20, PinballGame.boardBounds.top - 31.5,
), ),
); );
final launcherRamp = LauncherRamp( final launcherRamp = LauncherRamp(
position: Vector2( position: Vector2(
PinballGame.boardBounds.right - 23, PinballGame.boardBounds.right - 30,
PinballGame.boardBounds.bottom + 40, PinballGame.boardBounds.bottom + 40,
), ),
); );

Loading…
Cancel
Save