|
|
|
@ -269,159 +269,4 @@ void main() {
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
group('FlipperAnchor', () {
|
|
|
|
|
flameTester.test(
|
|
|
|
|
'position is at the left of the left Flipper',
|
|
|
|
|
(game) async {
|
|
|
|
|
final flipper = Flipper.fromSide(
|
|
|
|
|
side: BoardSide.left,
|
|
|
|
|
);
|
|
|
|
|
await game.ensureAdd(flipper);
|
|
|
|
|
|
|
|
|
|
final flipperAnchor = FlipperAnchor(flipper: flipper);
|
|
|
|
|
await game.ensureAdd(flipperAnchor);
|
|
|
|
|
|
|
|
|
|
expect(flipperAnchor.body.position.x, equals(-Flipper.size.x / 2));
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
flameTester.test(
|
|
|
|
|
'position is at the right of the right Flipper',
|
|
|
|
|
(game) async {
|
|
|
|
|
final flipper = Flipper.fromSide(
|
|
|
|
|
side: BoardSide.right,
|
|
|
|
|
);
|
|
|
|
|
await game.ensureAdd(flipper);
|
|
|
|
|
|
|
|
|
|
final flipperAnchor = FlipperAnchor(flipper: flipper);
|
|
|
|
|
await game.ensureAdd(flipperAnchor);
|
|
|
|
|
|
|
|
|
|
expect(flipperAnchor.body.position.x, equals(Flipper.size.x / 2));
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
group('FlipperAnchorRevoluteJointDef', () {
|
|
|
|
|
group('initializes with', () {
|
|
|
|
|
flameTester.test(
|
|
|
|
|
'limits enabled',
|
|
|
|
|
(game) async {
|
|
|
|
|
final flipper = Flipper.fromSide(
|
|
|
|
|
side: BoardSide.left,
|
|
|
|
|
);
|
|
|
|
|
await game.ensureAdd(flipper);
|
|
|
|
|
|
|
|
|
|
final flipperAnchor = FlipperAnchor(flipper: flipper);
|
|
|
|
|
await game.ensureAdd(flipperAnchor);
|
|
|
|
|
|
|
|
|
|
final jointDef = FlipperAnchorRevoluteJointDef(
|
|
|
|
|
flipper: flipper,
|
|
|
|
|
anchor: flipperAnchor,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(jointDef.enableLimit, isTrue);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
group('equal upper and lower limits', () {
|
|
|
|
|
flameTester.test(
|
|
|
|
|
'when Flipper is left',
|
|
|
|
|
(game) async {
|
|
|
|
|
final flipper = Flipper.fromSide(
|
|
|
|
|
side: BoardSide.left,
|
|
|
|
|
);
|
|
|
|
|
await game.ensureAdd(flipper);
|
|
|
|
|
|
|
|
|
|
final flipperAnchor = FlipperAnchor(flipper: flipper);
|
|
|
|
|
await game.ensureAdd(flipperAnchor);
|
|
|
|
|
|
|
|
|
|
final jointDef = FlipperAnchorRevoluteJointDef(
|
|
|
|
|
flipper: flipper,
|
|
|
|
|
anchor: flipperAnchor,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(jointDef.lowerAngle, equals(jointDef.upperAngle));
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
flameTester.test(
|
|
|
|
|
'when Flipper is right',
|
|
|
|
|
(game) async {
|
|
|
|
|
final flipper = Flipper.fromSide(
|
|
|
|
|
side: BoardSide.right,
|
|
|
|
|
);
|
|
|
|
|
await game.ensureAdd(flipper);
|
|
|
|
|
|
|
|
|
|
final flipperAnchor = FlipperAnchor(flipper: flipper);
|
|
|
|
|
await game.ensureAdd(flipperAnchor);
|
|
|
|
|
|
|
|
|
|
final jointDef = FlipperAnchorRevoluteJointDef(
|
|
|
|
|
flipper: flipper,
|
|
|
|
|
anchor: flipperAnchor,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(jointDef.lowerAngle, equals(jointDef.upperAngle));
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
group(
|
|
|
|
|
'unlocks',
|
|
|
|
|
() {
|
|
|
|
|
flameTester.test(
|
|
|
|
|
'when Flipper is left',
|
|
|
|
|
(game) async {
|
|
|
|
|
final flipper = Flipper.fromSide(
|
|
|
|
|
side: BoardSide.left,
|
|
|
|
|
);
|
|
|
|
|
await game.ensureAdd(flipper);
|
|
|
|
|
|
|
|
|
|
final flipperAnchor = FlipperAnchor(flipper: flipper);
|
|
|
|
|
await game.ensureAdd(flipperAnchor);
|
|
|
|
|
|
|
|
|
|
final jointDef = FlipperAnchorRevoluteJointDef(
|
|
|
|
|
flipper: flipper,
|
|
|
|
|
anchor: flipperAnchor,
|
|
|
|
|
);
|
|
|
|
|
final joint = game.world.createJoint(jointDef) as RevoluteJoint;
|
|
|
|
|
|
|
|
|
|
FlipperAnchorRevoluteJointDef.unlock(joint, flipper.side);
|
|
|
|
|
|
|
|
|
|
expect(
|
|
|
|
|
joint.upperLimit,
|
|
|
|
|
isNot(equals(joint.lowerLimit)),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
flameTester.test(
|
|
|
|
|
'when Flipper is right',
|
|
|
|
|
(game) async {
|
|
|
|
|
final flipper = Flipper.fromSide(
|
|
|
|
|
side: BoardSide.right,
|
|
|
|
|
);
|
|
|
|
|
await game.ensureAdd(flipper);
|
|
|
|
|
|
|
|
|
|
final flipperAnchor = FlipperAnchor(flipper: flipper);
|
|
|
|
|
await game.ensureAdd(flipperAnchor);
|
|
|
|
|
|
|
|
|
|
final jointDef = FlipperAnchorRevoluteJointDef(
|
|
|
|
|
flipper: flipper,
|
|
|
|
|
anchor: flipperAnchor,
|
|
|
|
|
);
|
|
|
|
|
final joint = game.world.createJoint(jointDef) as RevoluteJoint;
|
|
|
|
|
|
|
|
|
|
FlipperAnchorRevoluteJointDef.unlock(joint, flipper.side);
|
|
|
|
|
|
|
|
|
|
expect(
|
|
|
|
|
joint.upperLimit,
|
|
|
|
|
isNot(equals(joint.lowerLimit)),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|