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 {
await super.onLoad();
final joint = await _anchorToJoint();
const halfAnimationPeriod = (_framesInAnimation / 2) * _animationFPS;
await add(
TimerComponent(
period: halfAnimationPeriod,
period: (_framesInAnimation / 2) * _animationFPS,
onTick: joint._swivel,
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 {
/// {@macro chrome_dino_anchor}
_ChromeDinoAnchor();
// 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,
);
enableLimit = true;
const angle = _ChromeDinoJoint._halfSweepingAngle;
lowerAngle = -angle;
upperAngle = angle;
lowerAngle = -_ChromeDinoJoint._halfSweepingAngle;
upperAngle = _ChromeDinoJoint._halfSweepingAngle;
enableMotor = true;
maxMotorTorque = chromeDino.body.mass * 255;

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

Loading…
Cancel
Save