refactor: fix PR nits

pull/229/head
Allison Ryan 3 years ago
parent ce93f4d31b
commit 4530ad8aa5

@ -44,10 +44,9 @@ class ChromeDino extends BodyComponent with InitialPosition {
Future<void> onLoad() async { Future<void> onLoad() async {
await super.onLoad(); await super.onLoad();
final joint = await _anchorToJoint(); final joint = await _anchorToJoint();
const halfAnimationPeriod = (_framesInAnimation / 2) * _animationFPS;
await add( await add(
TimerComponent( TimerComponent(
period: halfAnimationPeriod, period: (_framesInAnimation / 2) * _animationFPS,
onTick: joint._swivel, onTick: joint._swivel,
repeat: true, repeat: true,
), ),
@ -86,11 +85,7 @@ class ChromeDino extends BodyComponent with InitialPosition {
} }
} }
/// {@template chrome_dino_anchor}
/// [JointAnchor] positioned at the back of the [ChromeDino].
/// {@endtemplate}
class _ChromeDinoAnchor extends JointAnchor { class _ChromeDinoAnchor extends JointAnchor {
/// {@macro chrome_dino_anchor}
_ChromeDinoAnchor(); _ChromeDinoAnchor();
// TODO(allisonryan0002): if these aren't moved when fixing the rendering, see // TODO(allisonryan0002): if these aren't moved when fixing the rendering, see
@ -120,9 +115,8 @@ class _ChromeDinoAnchorRevoluteJointDef extends RevoluteJointDef {
chromeDino.body.position + anchor.body.position, chromeDino.body.position + anchor.body.position,
); );
enableLimit = true; enableLimit = true;
const angle = _ChromeDinoJoint._halfSweepingAngle; lowerAngle = -_ChromeDinoJoint._halfSweepingAngle;
lowerAngle = -angle; upperAngle = _ChromeDinoJoint._halfSweepingAngle;
upperAngle = angle;
enableMotor = true; enableMotor = true;
maxMotorTorque = chromeDino.body.mass * 255; maxMotorTorque = chromeDino.body.mass * 255;

@ -65,14 +65,12 @@ void main() {
); );
group('swivels', () { group('swivels', () {
flameTester.testGameWidget( flameTester.test(
'up', 'up',
setUp: (game, tester) async { (game) async {
await game.images.loadAll(assets);
final chromeDino = ChromeDino(); final chromeDino = ChromeDino();
await game.ensureAdd(chromeDino); await game.ensureAdd(chromeDino);
game.camera.followVector2(Vector2.zero()); game.camera.followVector2(Vector2.zero());
await tester.pump();
final sweepAnimationDuration = game final sweepAnimationDuration = game
.descendants() .descendants()
@ -82,20 +80,17 @@ void main() {
.totalDuration() / .totalDuration() /
2; 2;
game.update(sweepAnimationDuration * 1.5); game.update(sweepAnimationDuration * 1.5);
await tester.pump();
expect(chromeDino.body.angularVelocity, isPositive); expect(chromeDino.body.angularVelocity, isPositive);
}, },
); );
flameTester.testGameWidget( flameTester.test(
'down', 'down',
setUp: (game, tester) async { (game) async {
await game.images.loadAll(assets);
final chromeDino = ChromeDino(); final chromeDino = ChromeDino();
await game.ensureAdd(chromeDino); await game.ensureAdd(chromeDino);
game.camera.followVector2(Vector2.zero()); game.camera.followVector2(Vector2.zero());
await tester.pump();
final sweepAnimationDuration = game final sweepAnimationDuration = game
.descendants() .descendants()
@ -105,7 +100,6 @@ void main() {
.totalDuration() / .totalDuration() /
2; 2;
game.update(sweepAnimationDuration * 0.5); game.update(sweepAnimationDuration * 0.5);
await tester.pump();
expect(chromeDino.body.angularVelocity, isNegative); expect(chromeDino.body.angularVelocity, isNegative);
}, },

Loading…
Cancel
Save