chore: bump flame versions (#185)

* chore: bumped version numbers

* refactor: resolved gravityScale problems

* chore: fix inverted y axis issues

* test: update tests related to y directions

* fix: unused math imports

* chore: flame version in sandbox

* fix: merge axis adjustments

Co-authored-by: alestiago <dev@alestiago.com>
pull/192/head
Allison Ryan 3 years ago committed by GitHub
parent f00d090e8d
commit 707e2e78b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 MiB

After

Width:  |  Height:  |  Size: 3.2 MiB

@ -25,9 +25,9 @@ class AlienZone extends Component with HasGameRef<PinballGame> {
gameRef.addContactCallback(_ControlledAlienBumperBallContactCallback());
final lowerBumper = ControlledAlienBumper.a()
..initialPosition = Vector2(-32.52, 9.34);
..initialPosition = Vector2(-32.52, -9.34);
final upperBumper = ControlledAlienBumper.b()
..initialPosition = Vector2(-22.89, 17.43);
..initialPosition = Vector2(-22.89, -17.43);
await addAll([
lowerBumper,

@ -23,7 +23,7 @@ class Board extends Component {
final dino = ChromeDino()
..initialPosition = Vector2(
BoardDimensions.bounds.center.dx + 25,
BoardDimensions.bounds.center.dy + 10,
BoardDimensions.bounds.center.dy - 10,
);
await addAll([
@ -77,17 +77,17 @@ class _BottomGroupSide extends Component {
final flipper = ControlledFlipper(
side: _side,
)..initialPosition = Vector2((11.8 * direction) + centerXAdjustment, -43.6);
)..initialPosition = Vector2((11.8 * direction) + centerXAdjustment, 43.6);
final baseboard = Baseboard(side: _side)
..initialPosition = Vector2(
(25.58 * direction) + centerXAdjustment,
-28.69,
28.69,
);
final kicker = Kicker(
side: _side,
)..initialPosition = Vector2(
(22.4 * direction) + centerXAdjustment,
-25,
25,
);
await addAll([flipper, baseboard, kicker]);

@ -78,9 +78,9 @@ class BonusWord extends Component
await super.onLoad();
final offsets = [
Vector2(-12.92, -1.82),
Vector2(-8.33, 0.65),
Vector2(-2.88, 1.75),
Vector2(-12.92, 1.82),
Vector2(-8.33, -0.65),
Vector2(-2.88, -1.75),
];
offsets.addAll(
offsets.reversed

@ -68,7 +68,7 @@ class BallController extends ComponentController<Ball>
await Future<void>.delayed(const Duration(seconds: 1));
component
..resume()
..boost(Vector2(200, -500));
..boost(Vector2(200, 500));
}
@override

@ -21,7 +21,7 @@ class ControlledSparkyComputer extends SparkyComputer
void build(Forge2DGame _) {
addContactCallback(SparkyTurboChargeSensorBallContactCallback());
final sparkyTurboChargeSensor = SparkyTurboChargeSensor()
..initialPosition = Vector2(-13, 49.8);
..initialPosition = Vector2(-13, -49.8);
add(sparkyTurboChargeSensor);
super.build(_);
}

@ -26,17 +26,17 @@ class FlutterForest extends Component with Controls<_FlutterForestController> {
@override
Future<void> onLoad() async {
await super.onLoad();
final signPost = FlutterSignPost()..initialPosition = Vector2(8.35, 58.3);
final signPost = FlutterSignPost()..initialPosition = Vector2(8.35, -58.3);
final bigNest = _ControlledBigDashNestBumper(
id: 'big_nest_bumper',
)..initialPosition = Vector2(18.55, 59.35);
)..initialPosition = Vector2(18.55, -59.35);
final smallLeftNest = _ControlledSmallDashNestBumper.a(
id: 'small_nest_bumper_a',
)..initialPosition = Vector2(8.95, 51.95);
)..initialPosition = Vector2(8.95, -51.95);
final smallRightNest = _ControlledSmallDashNestBumper.b(
id: 'small_nest_bumper_b',
)..initialPosition = Vector2(23.3, 46.75);
)..initialPosition = Vector2(23.3, -46.75);
final dashAnimatronic = DashAnimatronic()..position = Vector2(20, -66);
await addAll([
@ -78,7 +78,7 @@ class _FlutterForestController extends ComponentController<FlutterForest>
await Future<void>.delayed(const Duration(milliseconds: 700));
await gameRef.add(
ControlledBall.bonus(theme: gameRef.theme)
..initialPosition = Vector2(17.2, 52.7),
..initialPosition = Vector2(17.2, -52.7),
);
}
}

@ -16,7 +16,7 @@ class Launcher extends Forge2DBlueprint {
@override
void build(Forge2DGame gameRef) {
plunger = ControlledPlunger(compressionDistance: 12.3)
..initialPosition = Vector2(40.1, -38);
..initialPosition = Vector2(40.1, 38);
final _rocket = RocketSpriteComponent()..position = Vector2(43, 62);

@ -25,11 +25,11 @@ class SparkyFireZone extends Component with HasGameRef<PinballGame> {
gameRef.addContactCallback(_ControlledSparkyBumperBallContactCallback());
final lowerLeftBumper = ControlledSparkyBumper.a()
..initialPosition = Vector2(-23.15, 41.65);
..initialPosition = Vector2(-23.15, -41.65);
final upperLeftBumper = ControlledSparkyBumper.b()
..initialPosition = Vector2(-21.25, 58.15);
..initialPosition = Vector2(-21.25, -58.15);
final rightBumper = ControlledSparkyBumper.c()
..initialPosition = Vector2(-3.56, 53.051);
..initialPosition = Vector2(-3.56, -53.051);
await addAll([
lowerLeftBumper,

@ -15,10 +15,8 @@ extension PinballGameAssetsX on PinballGame {
images.load(components.Assets.images.baseboard.right.keyName),
images.load(components.Assets.images.kicker.left.keyName),
images.load(components.Assets.images.kicker.right.keyName),
images.load(components.Assets.images.slingshot.leftUpper.keyName),
images.load(components.Assets.images.slingshot.leftLower.keyName),
images.load(components.Assets.images.slingshot.rightUpper.keyName),
images.load(components.Assets.images.slingshot.rightLower.keyName),
images.load(components.Assets.images.slingshot.upper.keyName),
images.load(components.Assets.images.slingshot.lower.keyName),
images.load(components.Assets.images.launchRamp.ramp.keyName),
images.load(
components.Assets.images.launchRamp.foregroundRailing.keyName,

@ -59,15 +59,11 @@ class PinballGame extends Forge2DGame
unawaited(
addFromBlueprint(
Spaceship(
position: Vector2(-26.5, 28.5),
position: Vector2(-26.5, -28.5),
),
),
);
unawaited(
addFromBlueprint(
SpaceshipRail(),
),
);
unawaited(addFromBlueprint(SpaceshipRail()));
controller.attachTo(launcher.plunger);
await super.onLoad();
@ -88,8 +84,8 @@ class PinballGame extends Forge2DGame
await add(
BonusWord(
position: Vector2(
BoardDimensions.bounds.center.dx - 3.07,
BoardDimensions.bounds.center.dy - 2.4,
BoardDimensions.bounds.center.dx - 4.1,
BoardDimensions.bounds.center.dy + 1.8,
),
),
);
@ -127,7 +123,7 @@ class _GameBallsController extends ComponentController<PinballGame>
theme: gameRef.theme,
)..initialPosition = Vector2(
_plunger.body.position.x,
_plunger.body.position.y + Ball.size.y,
_plunger.body.position.y - Ball.size.y,
);
component.add(ball);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

@ -196,21 +196,13 @@ class $AssetsImagesPlungerGen {
class $AssetsImagesSlingshotGen {
const $AssetsImagesSlingshotGen();
/// File path: assets/images/slingshot/left_lower.png
AssetGenImage get leftLower =>
const AssetGenImage('assets/images/slingshot/left_lower.png');
/// File path: assets/images/slingshot/lower.png
AssetGenImage get lower =>
const AssetGenImage('assets/images/slingshot/lower.png');
/// File path: assets/images/slingshot/left_upper.png
AssetGenImage get leftUpper =>
const AssetGenImage('assets/images/slingshot/left_upper.png');
/// File path: assets/images/slingshot/right_lower.png
AssetGenImage get rightLower =>
const AssetGenImage('assets/images/slingshot/right_lower.png');
/// File path: assets/images/slingshot/right_upper.png
AssetGenImage get rightUpper =>
const AssetGenImage('assets/images/slingshot/right_upper.png');
/// File path: assets/images/slingshot/upper.png
AssetGenImage get upper =>
const AssetGenImage('assets/images/slingshot/upper.png');
}
class $AssetsImagesSpaceshipGen {

@ -1,5 +1,3 @@
import 'dart:math' as math;
import 'package:flame/components.dart';
import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:pinball_components/pinball_components.dart';
@ -73,7 +71,7 @@ class AlienBumper extends BodyComponent with InitialPosition {
center: Vector2.zero(),
majorRadius: _majorRadius,
minorRadius: _minorRadius,
)..rotate(15.9 * math.pi / 180);
)..rotate(1.29);
final fixtureDef = FixtureDef(shape)
..friction = 0
..restitution = 4;

@ -79,7 +79,7 @@ class Ball<T extends Forge2DGame> extends BodyComponent<T>
// TODO(allisonryan0002): prevent motion from contact with other balls.
void stop() {
body
..gravityScale = 0
..gravityScale = Vector2.zero()
..linearVelocity = Vector2.zero()
..angularVelocity = 0;
}
@ -88,7 +88,7 @@ class Ball<T extends Forge2DGame> extends BodyComponent<T>
///
/// If previously [stop]ped, the previous ball's velocity is not kept.
void resume() {
body.gravityScale = 1;
body.gravityScale = Vector2(0, 1);
}
@override
@ -99,8 +99,8 @@ class Ball<T extends Forge2DGame> extends BodyComponent<T>
final direction = body.linearVelocity.normalized();
final effect = FireEffect(
burstPower: _boostTimer,
direction: -direction,
position: Vector2(body.position.x, -body.position.y),
direction: direction,
position: Vector2(body.position.x, body.position.y),
priority: priority - 1,
);
@ -117,10 +117,10 @@ class Ball<T extends Forge2DGame> extends BodyComponent<T>
}
void _rescale() {
final boardHeight = BoardDimensions.size.y;
final boardHeight = BoardDimensions.bounds.height;
const maxShrinkAmount = BoardDimensions.perspectiveShrinkFactor;
final adjustedYPosition = body.position.y + (boardHeight / 2);
final adjustedYPosition = -body.position.y + (boardHeight / 2);
final scaleFactor = ((boardHeight - adjustedYPosition) /
BoardDimensions.shrinkAdjustedHeight) +

@ -19,37 +19,37 @@ class Baseboard extends BodyComponent with InitialPosition {
List<FixtureDef> _createFixtureDefs() {
final fixturesDef = <FixtureDef>[];
final direction = _side.direction;
final arcsAngle = -1.11 * direction;
const arcsRotation = math.pi / 2.08;
const arcsAngle = 1.11;
final arcsRotation = (_side.isLeft) ? -2.7 : -1.6;
final pegBumperShape = CircleShape()..radius = 0.7;
pegBumperShape.position.setValues(11.11 * direction, 7.15);
pegBumperShape.position.setValues(11.11 * direction, -7.15);
final pegBumperFixtureDef = FixtureDef(pegBumperShape);
fixturesDef.add(pegBumperFixtureDef);
final topCircleShape = CircleShape()..radius = 0.7;
topCircleShape.position.setValues(9.71 * direction, 4.95);
topCircleShape.position.setValues(9.71 * direction, -4.95);
final topCircleFixtureDef = FixtureDef(topCircleShape);
fixturesDef.add(topCircleFixtureDef);
final innerEdgeShape = EdgeShape()
..set(
Vector2(9.01 * direction, 5.35),
Vector2(5.29 * direction, -0.95),
Vector2(9.01 * direction, -5.35),
Vector2(5.29 * direction, 0.95),
);
final innerEdgeShapeFixtureDef = FixtureDef(innerEdgeShape);
fixturesDef.add(innerEdgeShapeFixtureDef);
final outerEdgeShape = EdgeShape()
..set(
Vector2(10.41 * direction, 4.75),
Vector2(3.79 * direction, -5.95),
Vector2(10.41 * direction, -4.75),
Vector2(3.79 * direction, 5.95),
);
final outerEdgeShapeFixtureDef = FixtureDef(outerEdgeShape);
fixturesDef.add(outerEdgeShapeFixtureDef);
final upperArcShape = ArcShape(
center: Vector2(0.09 * direction, 2.15),
center: Vector2(0.09 * direction, -2.15),
arcRadius: 6.1,
angle: arcsAngle,
rotation: arcsRotation,
@ -58,7 +58,7 @@ class Baseboard extends BodyComponent with InitialPosition {
fixturesDef.add(upperArcFixtureDef);
final lowerArcShape = ArcShape(
center: Vector2(0.09 * direction, -3.35),
center: Vector2(0.09 * direction, 3.35),
arcRadius: 4.5,
angle: arcsAngle,
rotation: arcsRotation,
@ -70,7 +70,7 @@ class Baseboard extends BodyComponent with InitialPosition {
..setAsBox(
6.8,
2,
Vector2(-6.3 * direction, -5.85),
Vector2(-6.3 * direction, 5.85),
0,
);
final bottomRectangleFixtureDef = FixtureDef(bottomRectangle);
@ -92,7 +92,7 @@ class Baseboard extends BodyComponent with InitialPosition {
final bodyDef = BodyDef()
..position = initialPosition
..angle = _side.isLeft ? -angle : angle;
..angle = _side.isLeft ? angle : -angle;
final body = world.createBody(bodyDef);
_createFixtureDefs().forEach(body.createFixture);

@ -14,7 +14,7 @@ class BoardDimensions {
static final bounds = Rect.fromCenter(
center: Offset.zero,
width: size.x,
height: -size.y,
height: size.y,
);
/// 3D perspective angle of the board in radians.

@ -30,9 +30,9 @@ class _BottomBoundary extends BodyComponent with InitialPosition {
final bottomLeftCurve = BezierCurveShape(
controlPoints: [
Vector2(-43.9, -41.8),
Vector2(-35.7, -43),
Vector2(-19.9, -51),
Vector2(-43.9, 41.8),
Vector2(-35.7, 43),
Vector2(-19.9, 51),
],
);
final bottomLeftCurveFixtureDef = FixtureDef(bottomLeftCurve);
@ -40,9 +40,9 @@ class _BottomBoundary extends BodyComponent with InitialPosition {
final bottomRightCurve = BezierCurveShape(
controlPoints: [
Vector2(31.8, -44.8),
Vector2(21.95, -47.7),
Vector2(12.3, -52.1),
Vector2(31.8, 44.8),
Vector2(21.95, 47.7),
Vector2(12.3, 52.1),
],
);
final bottomRightCurveFixtureDef = FixtureDef(bottomRightCurve);
@ -95,17 +95,17 @@ class _OuterBoundary extends BodyComponent with InitialPosition {
final topWall = EdgeShape()
..set(
Vector2(3.6, 70.2),
Vector2(-14.1, 70.2),
Vector2(3.6, -70.2),
Vector2(-14.1, -70.2),
);
final topWallFixtureDef = FixtureDef(topWall);
fixturesDefs.add(topWallFixtureDef);
final topLeftCurve = BezierCurveShape(
controlPoints: [
Vector2(-32.3, 57.2),
Vector2(-31.5, 69.9),
Vector2(-14.1, 70.2),
Vector2(-32.3, -57.2),
Vector2(-31.5, -69.9),
Vector2(-14.1, -70.2),
],
);
final topLeftCurveFixtureDef = FixtureDef(topLeftCurve);
@ -113,8 +113,8 @@ class _OuterBoundary extends BodyComponent with InitialPosition {
final leftWall = EdgeShape()
..set(
Vector2(-32.3, 57.2),
Vector2(-43.9, -41.8),
Vector2(-32.3, -57.2),
Vector2(-43.9, 41.8),
);
final leftWallFixtureDef = FixtureDef(leftWall);
fixturesDefs.add(leftWallFixtureDef);

@ -94,7 +94,7 @@ class ChromeDino extends BodyComponent with InitialPosition {
@override
Body createBody() {
final bodyDef = BodyDef()
..gravityScale = 0
..gravityScale = Vector2.zero()
..position = initialPosition
..type = BodyType.dynamic;

@ -77,7 +77,7 @@ class BigDashNestBumper extends DashNestBumper {
center: Vector2.zero(),
majorRadius: 5.1,
minorRadius: 3.75,
)..rotate(math.pi / 2.1);
)..rotate(math.pi / 1.9);
final fixtureDef = FixtureDef(shape);
final bodyDef = BodyDef()

@ -35,8 +35,8 @@ class _DinoTopWall extends BodyComponent with InitialPosition {
final topStraightShape = EdgeShape()
..set(
Vector2(29.5, 35.1),
Vector2(28.4, 35.1),
Vector2(28.4, -35.1),
Vector2(29.5, -35.1),
);
final topStraightFixtureDef = FixtureDef(topStraightShape);
fixturesDef.add(topStraightFixtureDef);
@ -44,8 +44,8 @@ class _DinoTopWall extends BodyComponent with InitialPosition {
final topCurveShape = BezierCurveShape(
controlPoints: [
topStraightShape.vertex1,
Vector2(17.4, 26.38),
Vector2(25.5, 20.7),
Vector2(17.4, -26.38),
Vector2(25.5, -20.7),
],
);
fixturesDef.add(FixtureDef(topCurveShape));
@ -53,8 +53,8 @@ class _DinoTopWall extends BodyComponent with InitialPosition {
final middleCurveShape = BezierCurveShape(
controlPoints: [
topCurveShape.vertices.last,
Vector2(27.8, 20.1),
Vector2(26.8, 19.5),
Vector2(27.8, -20.1),
Vector2(26.8, -19.5),
],
);
fixturesDef.add(FixtureDef(middleCurveShape));
@ -62,8 +62,8 @@ class _DinoTopWall extends BodyComponent with InitialPosition {
final bottomCurveShape = BezierCurveShape(
controlPoints: [
middleCurveShape.vertices.last,
Vector2(21.15, 16),
Vector2(25.6, 15.2),
Vector2(21.15, -16),
Vector2(25.6, -15.2),
],
);
fixturesDef.add(FixtureDef(bottomCurveShape));
@ -71,7 +71,7 @@ class _DinoTopWall extends BodyComponent with InitialPosition {
final bottomStraightShape = EdgeShape()
..set(
bottomCurveShape.vertices.last,
Vector2(31, 14.5),
Vector2(31, -14.5),
);
final bottomStraightFixtureDef = FixtureDef(bottomStraightShape);
fixturesDef.add(bottomStraightFixtureDef);
@ -130,8 +130,8 @@ class _DinoBottomWall extends BodyComponent with InitialPosition {
final fixturesDef = <FixtureDef>[];
final topStraightControlPoints = [
Vector2(32.4, 8.3),
Vector2(25, 7.7),
Vector2(32.4, -8.3),
Vector2(25, -7.7),
];
final topStraightShape = EdgeShape()
..set(
@ -143,8 +143,8 @@ class _DinoBottomWall extends BodyComponent with InitialPosition {
final topLeftCurveControlPoints = [
topStraightControlPoints.last,
Vector2(21.8, 7),
Vector2(29.5, -13.8),
Vector2(21.8, -7),
Vector2(29.5, 13.8),
];
final topLeftCurveShape = BezierCurveShape(
controlPoints: topLeftCurveControlPoints,
@ -153,7 +153,7 @@ class _DinoBottomWall extends BodyComponent with InitialPosition {
final bottomLeftStraightControlPoints = [
topLeftCurveControlPoints.last,
Vector2(31.8, -44.1),
Vector2(31.8, 44.1),
];
final bottomLeftStraightShape = EdgeShape()
..set(
@ -165,7 +165,7 @@ class _DinoBottomWall extends BodyComponent with InitialPosition {
final bottomStraightControlPoints = [
bottomLeftStraightControlPoints.last,
Vector2(37.8, -44.1),
Vector2(37.8, 44.1),
];
final bottomStraightShape = EdgeShape()
..set(

@ -73,7 +73,7 @@ class FireEffect extends ParticleSystemComponent {
spreadTween.transform(random.nextDouble()),
spreadTween.transform(random.nextDouble()),
);
final finalDirection = Vector2(direction.x, -direction.y) + spread;
final finalDirection = Vector2(direction.x, direction.y) + spread;
final speed = finalDirection * (burstPower * 20);
return AcceleratedParticle(

@ -32,13 +32,13 @@ class Flipper extends BodyComponent with KeyboardHandler, InitialPosition {
/// Applies downward linear velocity to the [Flipper], moving it to its
/// resting position.
void moveDown() {
body.linearVelocity = Vector2(0, -_speed);
body.linearVelocity = Vector2(0, _speed);
}
/// Applies upward linear velocity to the [Flipper], moving it to its highest
/// position.
void moveUp() {
body.linearVelocity = Vector2(0, _speed);
body.linearVelocity = Vector2(0, -_speed);
}
/// Anchors the [Flipper] to the [RevoluteJoint] that controls its arc motion.
@ -120,7 +120,7 @@ class Flipper extends BodyComponent with KeyboardHandler, InitialPosition {
Body createBody() {
final bodyDef = BodyDef()
..position = initialPosition
..gravityScale = 0
..gravityScale = Vector2.zero()
..type = BodyType.dynamic;
final body = world.createBody(bodyDef);
_createFixtureDefs().forEach(body.createFixture);
@ -161,7 +161,7 @@ class _FlipperAnchor extends JointAnchor {
initialPosition = Vector2(
(Flipper.size.x * flipper.side.direction) / 2 -
(1.65 * flipper.side.direction),
0.15,
-0.15,
);
}
}
@ -209,8 +209,8 @@ class _FlipperJoint extends RevoluteJoint {
void lock() {
const angle = _halfSweepingAngle;
setLimits(
-angle * side.direction,
-angle * side.direction,
angle * side.direction,
angle * side.direction,
);
}

@ -34,14 +34,14 @@ class Kicker extends BodyComponent with InitialPosition {
const quarterPi = math.pi / 4;
final upperCircle = CircleShape()..radius = 1.6;
upperCircle.position.setValues(0, -upperCircle.radius / 2);
upperCircle.position.setValues(0, upperCircle.radius / 2);
final upperCircleFixtureDef = FixtureDef(upperCircle)..friction = 0;
fixturesDefs.add(upperCircleFixtureDef);
final lowerCircle = CircleShape()..radius = 1.6;
lowerCircle.position.setValues(
size.x * -direction,
-size.y - 0.8,
size.y + 0.8,
);
final lowerCircleFixtureDef = FixtureDef(lowerCircle)..friction = 0;
fixturesDefs.add(lowerCircleFixtureDef);
@ -53,7 +53,7 @@ class Kicker extends BodyComponent with InitialPosition {
upperCircle.radius * direction,
0,
),
Vector2(2.5 * direction, -size.y + 2),
Vector2(2.5 * direction, size.y - 2),
);
final wallFacingLineFixtureDef = FixtureDef(wallFacingEdge)..friction = 0;
fixturesDefs.add(wallFacingLineFixtureDef);
@ -64,7 +64,7 @@ class Kicker extends BodyComponent with InitialPosition {
lowerCircle.position +
Vector2(
lowerCircle.radius * math.cos(quarterPi) * direction,
-lowerCircle.radius * math.sin(quarterPi),
lowerCircle.radius * math.sin(quarterPi),
),
);
final bottomLineFixtureDef = FixtureDef(bottomEdge)..friction = 0;
@ -75,12 +75,12 @@ class Kicker extends BodyComponent with InitialPosition {
upperCircle.position +
Vector2(
upperCircle.radius * math.cos(quarterPi) * -direction,
upperCircle.radius * math.sin(quarterPi),
-upperCircle.radius * math.sin(quarterPi),
),
lowerCircle.position +
Vector2(
lowerCircle.radius * math.cos(quarterPi) * -direction,
lowerCircle.radius * math.sin(quarterPi),
-lowerCircle.radius * math.sin(quarterPi),
),
);
@ -97,7 +97,7 @@ class Kicker extends BodyComponent with InitialPosition {
lowerCircle.position +
Vector2(
lowerCircle.radius * math.cos(quarterPi) * -direction,
-lowerCircle.radius * math.sin(quarterPi),
lowerCircle.radius * math.sin(quarterPi),
),
wallFacingEdge.vertex2,
],

@ -22,10 +22,10 @@ class LaunchRamp extends Forge2DBlueprint {
final launchRampForegroundRailing = _LaunchRampForegroundRailing();
final launchRampExit = _LaunchRampExit(rotation: math.pi / 2)
..initialPosition = Vector2(0.6, 34);
..initialPosition = Vector2(0.6, -34);
final launchRampCloseWall = _LaunchRampCloseWall()
..initialPosition = Vector2(4, 66.5);
..initialPosition = Vector2(4, -69.5);
addAll([
launchRampBase,
@ -50,50 +50,50 @@ class _LaunchRampBase extends BodyComponent with InitialPosition, Layered {
final rightStraightShape = EdgeShape()
..set(
Vector2(31.4, 61.4),
Vector2(46.5, -68.4),
Vector2(31.4, -61.4),
Vector2(46.5, 68.4),
);
final rightStraightFixtureDef = FixtureDef(rightStraightShape);
fixturesDef.add(rightStraightFixtureDef);
final leftStraightShape = EdgeShape()
..set(
Vector2(27.8, 61.4),
Vector2(41.5, -68.4),
Vector2(27.8, -61.4),
Vector2(41.5, 68.4),
);
final leftStraightFixtureDef = FixtureDef(leftStraightShape);
fixturesDef.add(leftStraightFixtureDef);
final topCurveShape = ArcShape(
center: Vector2(20.5, 61.1),
center: Vector2(20.5, -61.1),
arcRadius: 11,
angle: 1.6,
rotation: -1.65,
rotation: 0.1,
);
final topCurveFixtureDef = FixtureDef(topCurveShape);
fixturesDef.add(topCurveFixtureDef);
final bottomCurveShape = ArcShape(
center: Vector2(19.3, 60.3),
center: Vector2(19.3, -60.3),
arcRadius: 8.5,
angle: 1.48,
rotation: -1.58,
rotation: 0.1,
);
final bottomCurveFixtureDef = FixtureDef(bottomCurveShape);
fixturesDef.add(bottomCurveFixtureDef);
final topStraightShape = EdgeShape()
..set(
Vector2(3.7, 70.1),
Vector2(19.1, 72.1),
Vector2(3.7, -70.1),
Vector2(19.1, -72.1),
);
final topStraightFixtureDef = FixtureDef(topStraightShape);
fixturesDef.add(topStraightFixtureDef);
final bottomStraightShape = EdgeShape()
..set(
Vector2(3.7, 66.9),
Vector2(19.1, 68.8),
Vector2(3.7, -66.9),
Vector2(19.1, -68.8),
);
final bottomStraightFixtureDef = FixtureDef(bottomStraightShape);
fixturesDef.add(bottomStraightFixtureDef);
@ -150,25 +150,25 @@ class _LaunchRampForegroundRailing extends BodyComponent with InitialPosition {
final rightStraightShape = EdgeShape()
..set(
Vector2(27.6, 57.9),
Vector2(30, 35.1),
Vector2(27.6, -57.9),
Vector2(30, -35.1),
);
final rightStraightFixtureDef = FixtureDef(rightStraightShape);
fixturesDef.add(rightStraightFixtureDef);
final curveShape = ArcShape(
center: Vector2(20.1, 59.3),
center: Vector2(20.1, -59.3),
arcRadius: 7.5,
angle: 1.8,
rotation: -1.63,
rotation: -0.13,
);
final curveFixtureDef = FixtureDef(curveShape);
fixturesDef.add(curveFixtureDef);
final topStraightShape = EdgeShape()
..set(
Vector2(3.7, 66.8),
Vector2(19.7, 66.8),
Vector2(3.7, -66.8),
Vector2(19.7, -66.8),
);
final topStraightFixtureDef = FixtureDef(topStraightShape);
fixturesDef.add(topStraightFixtureDef);
@ -221,7 +221,7 @@ class _LaunchRampCloseWall extends BodyComponent with InitialPosition, Layered {
@override
Body createBody() {
final shape = EdgeShape()..set(Vector2.zero(), Vector2(0, 4));
final shape = EdgeShape()..set(Vector2.zero(), Vector2(0, 3));
final fixtureDef = FixtureDef(shape);

@ -37,14 +37,14 @@ class Plunger extends BodyComponent with InitialPosition, Layered {
..position = initialPosition
..userData = this
..type = BodyType.dynamic
..gravityScale = 0;
..gravityScale = Vector2.zero();
return world.createBody(bodyDef)..createFixture(fixtureDef);
}
/// Set a constant downward velocity on the [Plunger].
void pull() {
body.linearVelocity = Vector2(0, -7);
body.linearVelocity = Vector2(0, 7);
}
/// Set an upward velocity on the [Plunger].
@ -107,7 +107,7 @@ class PlungerAnchor extends JointAnchor {
}) {
initialPosition = Vector2(
0,
-plunger.compressionDistance,
plunger.compressionDistance,
);
}
}

@ -112,9 +112,9 @@ class RampOpeningBallContactCallback<Opening extends RampOpening>
// now doesn't work position.y comparison
final isBallOutsideOpening =
(opening.orientation == RampOrientation.down &&
ball.body.linearVelocity.y < 0) ||
ball.body.linearVelocity.y > 0) ||
(opening.orientation == RampOrientation.up &&
ball.body.linearVelocity.y > 0);
ball.body.linearVelocity.y < 0);
if (isBallOutsideOpening) {
ball

@ -1,47 +1,31 @@
// ignore_for_file: avoid_renaming_method_parameters
import 'dart:math' as math;
import 'package:flame/components.dart';
import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:pinball_components/pinball_components.dart';
/// {@template slingshots}
/// A [Blueprint] which creates the left and right pairs of [Slingshot]s.
/// A [Blueprint] which creates the pair of [Slingshot]s on the right side of
/// the board.
/// {@endtemplate}
class Slingshots extends Forge2DBlueprint {
@override
void build(_) {
// TODO(allisonryan0002): use radians values instead of converting degrees.
final leftUpperSlingshot = Slingshot(
length: 5.66,
angle: -1.5 * (math.pi / 180),
spritePath: Assets.images.slingshot.leftUpper.keyName,
)..initialPosition = Vector2(-29, 1.5);
final leftLowerSlingshot = Slingshot(
length: 3.54,
angle: -29.1 * (math.pi / 180),
spritePath: Assets.images.slingshot.leftLower.keyName,
)..initialPosition = Vector2(-31, -6.2);
final rightUpperSlingshot = Slingshot(
final upperSlingshot = Slingshot(
length: 5.64,
angle: 1 * (math.pi / 180),
spritePath: Assets.images.slingshot.rightUpper.keyName,
)..initialPosition = Vector2(22.3, 1.58);
angle: -0.017,
spritePath: Assets.images.slingshot.upper.keyName,
)..initialPosition = Vector2(22.3, -1.58);
final rightLowerSlingshot = Slingshot(
final lowerSlingshot = Slingshot(
length: 3.46,
angle: 26.8 * (math.pi / 180),
spritePath: Assets.images.slingshot.rightLower.keyName,
)..initialPosition = Vector2(24.7, -6.2);
angle: -0.468,
spritePath: Assets.images.slingshot.lower.keyName,
)..initialPosition = Vector2(24.7, 6.2);
addAll([
leftUpperSlingshot,
leftLowerSlingshot,
rightUpperSlingshot,
rightLowerSlingshot,
upperSlingshot,
lowerSlingshot,
]);
}
}
@ -71,12 +55,12 @@ class Slingshot extends BodyComponent with InitialPosition {
const circleRadius = 1.55;
final topCircleShape = CircleShape()..radius = circleRadius;
topCircleShape.position.setValues(0, _length / 2);
topCircleShape.position.setValues(0, -_length / 2);
final topCircleFixtureDef = FixtureDef(topCircleShape)..friction = 0;
fixturesDef.add(topCircleFixtureDef);
final bottomCircleShape = CircleShape()..radius = circleRadius;
bottomCircleShape.position.setValues(0, -_length / 2);
bottomCircleShape.position.setValues(0, _length / 2);
final bottomCircleFixtureDef = FixtureDef(bottomCircleShape)..friction = 0;
fixturesDef.add(bottomCircleFixtureDef);
@ -131,7 +115,7 @@ class Slingshot extends BodyComponent with InitialPosition {
sprite: sprite,
size: sprite.originalSize / 10,
anchor: Anchor.center,
angle: _angle,
angle: -_angle,
),
);
}

@ -35,8 +35,8 @@ class Spaceship extends Forge2DBlueprint {
SpaceshipHole(
outsideLayer: Layer.spaceshipExitRail,
outsidePriority: Ball.spaceshipRailPriority,
)..initialPosition = position - Vector2(5.2, 4.8),
SpaceshipHole()..initialPosition = position - Vector2(-7.2, 0.8),
)..initialPosition = position - Vector2(5.2, -4.8),
SpaceshipHole()..initialPosition = position - Vector2(-7.2, -0.8),
SpaceshipWall()..initialPosition = position,
]);
}
@ -197,10 +197,10 @@ class SpaceshipHole extends RampOpening {
@override
Shape get shape {
return ArcShape(
center: Vector2(0, 3.2),
center: Vector2(0, -3.2),
arcRadius: 5,
angle: 1,
rotation: 60 * pi / 180,
rotation: -2,
);
}
}
@ -251,7 +251,7 @@ class SpaceshipWall extends BodyComponent with InitialPosition, Layered {
final bodyDef = BodyDef()
..userData = this
..position = initialPosition
..angle = 90 * pi / 172
..angle = -1.7
..type = BodyType.static;
return world.createBody(bodyDef)

@ -23,9 +23,9 @@ class SpaceshipRail extends Forge2DBlueprint {
final railRamp = _SpaceshipRailRamp();
final railEnd = SpaceshipRailExit();
final topBase = _SpaceshipRailBase(radius: 0.55)
..initialPosition = Vector2(-26.15, 18.65);
..initialPosition = Vector2(-26.15, -18.65);
final bottomBase = _SpaceshipRailBase(radius: 0.8)
..initialPosition = Vector2(-25.5, -12.9);
..initialPosition = Vector2(-25.5, 12.9);
final railForeground = _SpaceshipRailForeground();
addAll([
@ -51,19 +51,19 @@ class _SpaceshipRailRamp extends BodyComponent with InitialPosition, Layered {
final fixturesDefs = <FixtureDef>[];
final topArcShape = ArcShape(
center: Vector2(-35.5, 30.9),
center: Vector2(-35.5, -30.9),
arcRadius: 2.5,
angle: math.pi,
rotation: 2.9,
rotation: 0.2,
);
final topArcFixtureDef = FixtureDef(topArcShape);
fixturesDefs.add(topArcFixtureDef);
final topLeftCurveShape = BezierCurveShape(
controlPoints: [
Vector2(-37.9, 30.4),
Vector2(-38, 23.9),
Vector2(-30.93, 18.2),
Vector2(-37.9, -30.4),
Vector2(-38, -23.9),
Vector2(-30.93, -18.2),
],
);
final topLeftCurveFixtureDef = FixtureDef(topLeftCurveShape);
@ -72,8 +72,8 @@ class _SpaceshipRailRamp extends BodyComponent with InitialPosition, Layered {
final middleLeftCurveShape = BezierCurveShape(
controlPoints: [
topLeftCurveShape.vertices.last,
Vector2(-22.6, 10.3),
Vector2(-30, 0.2),
Vector2(-22.6, -10.3),
Vector2(-30, -0.2),
],
);
final middleLeftCurveFixtureDef = FixtureDef(middleLeftCurveShape);
@ -82,8 +82,8 @@ class _SpaceshipRailRamp extends BodyComponent with InitialPosition, Layered {
final bottomLeftCurveShape = BezierCurveShape(
controlPoints: [
middleLeftCurveShape.vertices.last,
Vector2(-36, -8.6),
Vector2(-32.04, -18.3),
Vector2(-36, 8.6),
Vector2(-32.04, 18.3),
],
);
final bottomLeftCurveFixtureDef = FixtureDef(bottomLeftCurveShape);
@ -91,8 +91,8 @@ class _SpaceshipRailRamp extends BodyComponent with InitialPosition, Layered {
final topRightStraightShape = EdgeShape()
..set(
Vector2(-33, 31.3),
Vector2(-27.2, 21.3),
Vector2(-33, -31.3),
Vector2(-27.2, -21.3),
);
final topRightStraightFixtureDef = FixtureDef(topRightStraightShape);
fixturesDefs.add(topRightStraightFixtureDef);
@ -100,8 +100,8 @@ class _SpaceshipRailRamp extends BodyComponent with InitialPosition, Layered {
final middleRightCurveShape = BezierCurveShape(
controlPoints: [
topRightStraightShape.vertex1,
Vector2(-16.5, 11.4),
Vector2(-25.29, -1.7),
Vector2(-16.5, -11.4),
Vector2(-25.29, 1.7),
],
);
final middleRightCurveFixtureDef = FixtureDef(middleRightCurveShape);
@ -110,8 +110,8 @@ class _SpaceshipRailRamp extends BodyComponent with InitialPosition, Layered {
final bottomRightCurveShape = BezierCurveShape(
controlPoints: [
middleRightCurveShape.vertices.last,
Vector2(-29.91, -8.5),
Vector2(-26.8, -15.7),
Vector2(-29.91, 8.5),
Vector2(-26.8, 15.7),
],
);
final bottomRightCurveFixtureDef = FixtureDef(bottomRightCurveShape);
@ -219,10 +219,10 @@ class SpaceshipRailExit extends RampOpening {
@override
Shape get shape {
return ArcShape(
center: Vector2(-29, -19),
center: Vector2(-29, 19),
arcRadius: 2.5,
angle: math.pi * 0.4,
rotation: 0.26,
rotation: -1.4,
);
}
}

@ -25,14 +25,14 @@ class SpaceshipRamp extends Forge2DBlueprint {
outsidePriority: 1,
rotation: math.pi,
)
..initialPosition = Vector2(1.7, 19.8)
..initialPosition = Vector2(1.7, -19.8)
..layer = Layer.opening;
final leftOpening = _SpaceshipRampOpening(
outsideLayer: Layer.spaceship,
outsidePriority: Ball.spaceshipPriority,
rotation: math.pi,
)
..initialPosition = Vector2(-13.7, 18.6)
..initialPosition = Vector2(-13.7, -18.6)
..layer = Layer.spaceshipEntranceRamp;
final spaceshipRamp = _SpaceshipRampBackground();
@ -43,7 +43,7 @@ class SpaceshipRamp extends Forge2DBlueprint {
final spaceshipRampForegroundRailing = _SpaceshipRampForegroundRailing();
final baseRight = _SpaceshipRampBase()..initialPosition = Vector2(1.7, 20);
final baseRight = _SpaceshipRampBase()..initialPosition = Vector2(1.7, -20);
addAll([
spaceshipRampBoardOpeningSprite,
@ -70,9 +70,9 @@ class _SpaceshipRampBackground extends BodyComponent
final outerLeftCurveShape = BezierCurveShape(
controlPoints: [
Vector2(-30.75, 37.3),
Vector2(-32.5, 71.25),
Vector2(-14.2, 71.25),
Vector2(-30.75, -37.3),
Vector2(-32.5, -71.25),
Vector2(-14.2, -71.25),
],
);
@ -82,8 +82,8 @@ class _SpaceshipRampBackground extends BodyComponent
final outerRightCurveShape = BezierCurveShape(
controlPoints: [
outerLeftCurveShape.vertices.last,
Vector2(2.5, 71.9),
Vector2(6.1, 44.9),
Vector2(2.5, -71.9),
Vector2(6.1, -44.9),
],
);
@ -93,7 +93,7 @@ class _SpaceshipRampBackground extends BodyComponent
final boardOpeningEdgeShape = EdgeShape()
..set(
outerRightCurveShape.vertices.last,
Vector2(7.3, 41.1),
Vector2(7.3, -41.1),
);
final boardOpeningEdgeShapeFixtureDef = FixtureDef(boardOpeningEdgeShape);
fixturesDef.add(boardOpeningEdgeShapeFixtureDef);
@ -179,9 +179,9 @@ class _SpaceshipRampForegroundRailing extends BodyComponent
final innerLeftCurveShape = BezierCurveShape(
controlPoints: [
Vector2(-24.5, 38),
Vector2(-26.3, 64),
Vector2(-13.8, 64.5),
Vector2(-24.5, -38),
Vector2(-26.3, -64),
Vector2(-13.8, -64.5),
],
);
@ -191,8 +191,8 @@ class _SpaceshipRampForegroundRailing extends BodyComponent
final innerRightCurveShape = BezierCurveShape(
controlPoints: [
innerLeftCurveShape.vertices.last,
Vector2(-2.5, 66.2),
Vector2(0, 44.5),
Vector2(-2.5, -66.2),
Vector2(0, -44.5),
],
);
@ -202,7 +202,7 @@ class _SpaceshipRampForegroundRailing extends BodyComponent
final boardOpeningEdgeShape = EdgeShape()
..set(
innerRightCurveShape.vertices.last,
Vector2(-0.85, 40.8),
Vector2(-0.85, -40.8),
);
final boardOpeningEdgeShapeFixtureDef = FixtureDef(boardOpeningEdgeShape);
fixturesDef.add(boardOpeningEdgeShapeFixtureDef);
@ -259,9 +259,9 @@ class _SpaceshipRampBase extends BodyComponent with InitialPosition, Layered {
controlPoints: [
Vector2(initialPosition.x - baseWidth / 2, initialPosition.y),
Vector2(initialPosition.x - baseWidth / 2, initialPosition.y) +
Vector2(2, 5),
Vector2(2, -5),
Vector2(initialPosition.x + baseWidth / 2, initialPosition.y) +
Vector2(-2, 5),
Vector2(-2, -5),
Vector2(initialPosition.x + baseWidth / 2, initialPosition.y)
],
);

@ -89,7 +89,7 @@ class SparkyBumper extends BodyComponent with InitialPosition {
center: Vector2.zero(),
majorRadius: _majorRadius,
minorRadius: _minorRadius,
)..rotate(math.pi / 1.9);
)..rotate(math.pi / 2.1);
final fixtureDef = FixtureDef(shape)
..friction = 0
..restitution = 4;

@ -29,24 +29,24 @@ class _ComputerBase extends BodyComponent with InitialPosition {
final leftEdge = EdgeShape()
..set(
Vector2(-14.9, 46),
Vector2(-15.3, 49.6),
Vector2(-14.9, -46),
Vector2(-15.3, -49.6),
);
final leftEdgeFixtureDef = FixtureDef(leftEdge);
fixturesDef.add(leftEdgeFixtureDef);
final topEdge = EdgeShape()
..set(
Vector2(-15.3, 49.6),
Vector2(-10.7, 50.6),
Vector2(-15.3, -49.6),
Vector2(-10.7, -50.6),
);
final topEdgeFixtureDef = FixtureDef(topEdge);
fixturesDef.add(topEdgeFixtureDef);
final rightEdge = EdgeShape()
..set(
Vector2(-10.7, 50.6),
Vector2(-9, 47.2),
Vector2(-10.7, -50.6),
Vector2(-9, -47.2),
);
final rightEdgeFixtureDef = FixtureDef(rightEdge);
fixturesDef.add(rightEdgeFixtureDef);

@ -7,8 +7,8 @@ environment:
sdk: ">=2.16.0 <3.0.0"
dependencies:
flame: ^1.1.0
flame_forge2d: ^0.10.0
flame: ^1.1.1
flame_forge2d: ^0.11.0
flutter:
sdk: flutter
geometry:

@ -91,14 +91,14 @@ packages:
name: flame
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
flame_forge2d:
dependency: "direct main"
description:
name: flame_forge2d
url: "https://pub.dartlang.org"
source: hosted
version: "0.10.0"
version: "0.11.0"
flutter:
dependency: "direct main"
description: flutter
@ -134,7 +134,7 @@ packages:
name: forge2d
url: "https://pub.dartlang.org"
source: hosted
version: "0.10.0"
version: "0.11.0"
freezed_annotation:
dependency: transitive
description:

@ -8,8 +8,8 @@ environment:
dependencies:
dashbook: ^0.1.7
flame: ^1.1.0
flame_forge2d: ^0.10.0
flame: ^1.1.1
flame_forge2d: ^0.11.0
flutter:
sdk: flutter
pinball_components:

@ -48,7 +48,7 @@ void main() {
final ball = Ball(baseColor: Colors.blue);
await game.ensureAdd(ball);
ball.body.gravityScale = 0;
ball.body.gravityScale = Vector2.zero();
ball.body.linearVelocity.setValues(10, 10);
game.update(1);
expect(ball.body.position, isNot(equals(ball.initialPosition)));
@ -153,7 +153,7 @@ void main() {
ball.stop();
ball.resume();
ball.body.gravityScale = 0;
ball.body.gravityScale = Vector2.zero();
ball.body.linearVelocity.setValues(10, 10);
game.update(1);
expect(ball.body.position, isNot(equals(ball.initialPosition)));

@ -76,8 +76,8 @@ void main() {
);
await game.ensureAddAll([leftBaseboard, rightBaseboard]);
expect(leftBaseboard.body.angle, isNegative);
expect(rightBaseboard.body.angle, isPositive);
expect(leftBaseboard.body.angle, isPositive);
expect(rightBaseboard.body.angle, isNegative);
},
);
});

@ -75,7 +75,7 @@ void main() {
final flipper = Flipper(side: BoardSide.left);
await game.ensureAdd(flipper);
expect(flipper.body.gravityScale, isZero);
expect(flipper.body.gravityScale, equals(Vector2.zero()));
},
);
@ -133,7 +133,7 @@ void main() {
expect(flipper.body.linearVelocity, equals(Vector2.zero()));
flipper.moveDown();
expect(flipper.body.linearVelocity.y, lessThan(0));
expect(flipper.body.linearVelocity.y, isPositive);
},
);
@ -146,7 +146,7 @@ void main() {
expect(flipper.body.linearVelocity, equals(Vector2.zero()));
flipper.moveUp();
expect(flipper.body.linearVelocity.y, greaterThan(0));
expect(flipper.body.linearVelocity.y, isNegative);
},
);
});

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 78 KiB

@ -64,7 +64,7 @@ void main() {
);
await game.ensureAdd(plunger);
expect(plunger.body.gravityScale, isZero);
expect(plunger.body.gravityScale, equals(Vector2.zero()));
},
);
});
@ -119,7 +119,7 @@ void main() {
await game.ensureAdd(plunger);
plunger.pull();
expect(plunger.body.linearVelocity.y, isNegative);
expect(plunger.body.linearVelocity.y, isPositive);
expect(plunger.body.linearVelocity.x, isZero);
},
);
@ -138,10 +138,10 @@ void main() {
'moves upwards when release is called '
'and plunger is below its starting position', (game) async {
await game.ensureAdd(plunger);
plunger.body.setTransform(Vector2(0, -1), 0);
plunger.body.setTransform(Vector2(0, 1), 0);
plunger.release();
expect(plunger.body.linearVelocity.y, isPositive);
expect(plunger.body.linearVelocity.y, isNegative);
expect(plunger.body.linearVelocity.x, isZero);
});
@ -175,7 +175,7 @@ void main() {
expect(
plungerAnchor.body.position.y,
equals(plunger.body.position.y - compressionDistance),
equals(plunger.body.position.y + compressionDistance),
);
},
);
@ -292,7 +292,7 @@ void main() {
await tester.pump(const Duration(seconds: 1));
},
verify: (game, tester) async {
expect(plunger.body.position.y > anchor.body.position.y, isTrue);
expect(plunger.body.position.y < anchor.body.position.y, isTrue);
},
);

@ -180,7 +180,7 @@ void main() {
when(() => ball.body).thenReturn(body);
when(() => ball.priority).thenReturn(1);
when(() => body.position).thenReturn(Vector2.zero());
when(() => body.linearVelocity).thenReturn(Vector2(0, -1));
when(() => body.linearVelocity).thenReturn(Vector2(0, 1));
when(() => ball.layer).thenReturn(Layer.board);
callback.begin(ball, area, MockContact());
@ -205,7 +205,7 @@ void main() {
when(() => ball.body).thenReturn(body);
when(() => ball.priority).thenReturn(1);
when(() => body.position).thenReturn(Vector2.zero());
when(() => body.linearVelocity).thenReturn(Vector2(0, 1));
when(() => body.linearVelocity).thenReturn(Vector2(0, -1));
when(() => ball.layer).thenReturn(Layer.board);
callback.begin(ball, area, MockContact());
@ -230,7 +230,7 @@ void main() {
when(() => ball.body).thenReturn(body);
when(() => ball.priority).thenReturn(1);
when(() => body.position).thenReturn(Vector2.zero());
when(() => body.linearVelocity).thenReturn(Vector2(0, 1));
when(() => body.linearVelocity).thenReturn(Vector2(0, -1));
when(() => ball.layer).thenReturn(Layer.board);
callback.begin(ball, area, MockContact());

@ -12,7 +12,7 @@ void main() {
final flameTester = FlameTester(TestGame.new);
const length = 2.0;
const angle = 0.0;
final spritePath = Assets.images.slingshot.leftUpper.keyName;
final spritePath = Assets.images.slingshot.upper.keyName;
flameTester.testGameWidget(
'renders correctly',

@ -43,7 +43,9 @@ void main() {
tester.testGameWidget(
'renders correctly',
setUp: (game, tester) async {
await game.addFromBlueprint(Spaceship(position: Vector2(30, -30)));
final position = Vector2(30, -30);
await game.addFromBlueprint(Spaceship(position: position));
game.camera.followVector2(position);
},
verify: (game, tester) async {
await expectLater(

@ -196,7 +196,7 @@ packages:
name: flame
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
flame_audio:
dependency: transitive
description:
@ -217,7 +217,7 @@ packages:
name: flame_forge2d
url: "https://pub.dartlang.org"
source: hosted
version: "0.10.0"
version: "0.11.0"
flame_test:
dependency: "direct dev"
description:
@ -258,7 +258,7 @@ packages:
name: forge2d
url: "https://pub.dartlang.org"
source: hosted
version: "0.10.0"
version: "0.11.0"
frontend_server_client:
dependency: transitive
description:

@ -10,9 +10,9 @@ dependencies:
bloc: ^8.0.2
cloud_firestore: ^3.1.10
equatable: ^2.0.3
flame: ^1.1.0
flame: ^1.1.1
flame_bloc: ^1.2.0
flame_forge2d: ^0.10.0
flame_forge2d: ^0.11.0
flutter:
sdk: flutter
flutter_bloc: ^8.0.1

@ -42,7 +42,7 @@ void main() {
await game.add(flipper);
controller.onKeyEvent(event, {});
expect(flipper.body.linearVelocity.y, isPositive);
expect(flipper.body.linearVelocity.y, isNegative);
expect(flipper.body.linearVelocity.x, isZero);
},
);
@ -57,7 +57,7 @@ void main() {
await game.add(flipper);
controller.onKeyEvent(event, {});
expect(flipper.body.linearVelocity.y, isNegative);
expect(flipper.body.linearVelocity.y, isPositive);
expect(flipper.body.linearVelocity.x, isZero);
},
);
@ -77,21 +77,6 @@ void main() {
},
);
});
testRawKeyDownEvents(rightKeys, (event) {
flameTester.test(
'does nothing '
'when ${event.logicalKey.keyLabel} is pressed',
(game) async {
await game.ready();
await game.add(flipper);
controller.onKeyEvent(event, {});
expect(flipper.body.linearVelocity.y, isZero);
expect(flipper.body.linearVelocity.x, isZero);
},
);
});
});
group('and Flipper is right', () {
@ -113,7 +98,7 @@ void main() {
await game.add(flipper);
controller.onKeyEvent(event, {});
expect(flipper.body.linearVelocity.y, isPositive);
expect(flipper.body.linearVelocity.y, isNegative);
expect(flipper.body.linearVelocity.x, isZero);
},
);
@ -128,7 +113,7 @@ void main() {
await game.add(flipper);
controller.onKeyEvent(event, {});
expect(flipper.body.linearVelocity.y, isNegative);
expect(flipper.body.linearVelocity.y, isPositive);
expect(flipper.body.linearVelocity.x, isZero);
},
);
@ -148,21 +133,6 @@ void main() {
},
);
});
testRawKeyDownEvents(leftKeys, (event) {
flameTester.test(
'does nothing '
'when ${event.logicalKey.keyLabel} is pressed',
(game) async {
await game.ready();
await game.add(flipper);
controller.onKeyEvent(event, {});
expect(flipper.body.linearVelocity.y, isZero);
expect(flipper.body.linearVelocity.x, isZero);
},
);
});
});
});
});

@ -38,7 +38,7 @@ void main() {
await game.ensureAdd(plunger);
controller.onKeyEvent(event, {});
expect(plunger.body.linearVelocity.y, isNegative);
expect(plunger.body.linearVelocity.y, isPositive);
expect(plunger.body.linearVelocity.x, isZero);
},
);
@ -51,10 +51,10 @@ void main() {
'and plunger is below its starting position',
(game) async {
await game.ensureAdd(plunger);
plunger.body.setTransform(Vector2(0, -1), 0);
plunger.body.setTransform(Vector2(0, 1), 0);
controller.onKeyEvent(event, {});
expect(plunger.body.linearVelocity.y, isPositive);
expect(plunger.body.linearVelocity.y, isNegative);
expect(plunger.body.linearVelocity.x, isZero);
},
);

Loading…
Cancel
Save