From 663da20580617966d26dede2c4be09d7b3fe5152 Mon Sep 17 00:00:00 2001 From: Allison Ryan Date: Wed, 27 Apr 2022 16:42:53 -0500 Subject: [PATCH] refactor: dino variable and comment fixes --- .../lib/src/components/chrome_dino.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/pinball_components/lib/src/components/chrome_dino.dart b/packages/pinball_components/lib/src/components/chrome_dino.dart index 4b14e673..a3032357 100644 --- a/packages/pinball_components/lib/src/components/chrome_dino.dart +++ b/packages/pinball_components/lib/src/components/chrome_dino.dart @@ -19,6 +19,10 @@ class ChromeDino extends BodyComponent with InitialPosition { /// The size of the dinosaur mouth. static final size = Vector2(5.5, 5); + static const _framesInAnimation = 98; + + static const _animationFPS = 1 / 24; + /// Anchors the [ChromeDino] to the [RevoluteJoint] that controls its arc /// motion. Future<_ChromeDinoJoint> _anchorToJoint() async { @@ -40,9 +44,10 @@ class ChromeDino extends BodyComponent with InitialPosition { Future onLoad() async { await super.onLoad(); final joint = await _anchorToJoint(); + const halfAnimationPeriod = (_framesInAnimation / 2) * _animationFPS; await add( TimerComponent( - period: 98 / 48, + period: halfAnimationPeriod, onTick: joint._swivel, repeat: true, ), @@ -126,7 +131,6 @@ class _ChromeDinoAnchorRevoluteJointDef extends RevoluteJointDef { class _ChromeDinoJoint extends RevoluteJoint { _ChromeDinoJoint(_ChromeDinoAnchorRevoluteJointDef def) : super(def); - /// Half the angle of the arc motion. static const _halfSweepingAngle = 0.1143; /// Sweeps the [ChromeDino] up and down repeatedly.