refactor: dino variable and comment fixes

pull/229/head
Allison Ryan 3 years ago
parent 1c4e69d408
commit 663da20580

@ -19,6 +19,10 @@ class ChromeDino extends BodyComponent with InitialPosition {
/// The size of the dinosaur mouth. /// The size of the dinosaur mouth.
static final size = Vector2(5.5, 5); 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 /// Anchors the [ChromeDino] to the [RevoluteJoint] that controls its arc
/// motion. /// motion.
Future<_ChromeDinoJoint> _anchorToJoint() async { Future<_ChromeDinoJoint> _anchorToJoint() async {
@ -40,9 +44,10 @@ 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: 98 / 48, period: halfAnimationPeriod,
onTick: joint._swivel, onTick: joint._swivel,
repeat: true, repeat: true,
), ),
@ -126,7 +131,6 @@ class _ChromeDinoAnchorRevoluteJointDef extends RevoluteJointDef {
class _ChromeDinoJoint extends RevoluteJoint { class _ChromeDinoJoint extends RevoluteJoint {
_ChromeDinoJoint(_ChromeDinoAnchorRevoluteJointDef def) : super(def); _ChromeDinoJoint(_ChromeDinoAnchorRevoluteJointDef def) : super(def);
/// Half the angle of the arc motion.
static const _halfSweepingAngle = 0.1143; static const _halfSweepingAngle = 0.1143;
/// Sweeps the [ChromeDino] up and down repeatedly. /// Sweeps the [ChromeDino] up and down repeatedly.

Loading…
Cancel
Save