refactor: dimension boundaries according to designs (#75)

* refactor: correctly dimension boundaries

* refactor: adjust zoom level
pull/77/head
Allison Ryan 2 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(
position: Vector2(
PinballGame.boardBounds.right - 20,
PinballGame.boardBounds.top - 20,
PinballGame.boardBounds.center.dx + 20,
PinballGame.boardBounds.center.dy + 48,
),
);

@ -40,13 +40,13 @@ class JetpackRamp extends Component with HasGameRef<PinballGame> {
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([

@ -26,29 +26,33 @@ class LauncherRamp extends Component with HasGameRef<PinballGame> {
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([

@ -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([

@ -41,11 +41,13 @@ class Wall extends BodyComponent {
/// Create top, left, and right [Wall]s for the game board.
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 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),

@ -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<void> _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<void> _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,
),
);

Loading…
Cancel
Save