refactor: remove docs and size

pull/258/head
Allison Ryan 3 years ago
parent 15d1f79cfb
commit 5121dd6663

@ -1,3 +1,5 @@
// ignore_for_file: public_member_api_docs
import 'dart:async'; import 'dart:async';
import 'dart:math' as math; import 'dart:math' as math;
@ -7,11 +9,7 @@ import 'package:pinball_components/gen/assets.gen.dart';
import 'package:pinball_components/pinball_components.dart' hide Assets; import 'package:pinball_components/pinball_components.dart' hide Assets;
import 'package:pinball_flame/pinball_flame.dart'; import 'package:pinball_flame/pinball_flame.dart';
/// {@template android_spaceship}
/// A [Blueprint] which creates the Android spaceship.
/// {@endtemplate}
class AndroidSpaceship extends Blueprint { class AndroidSpaceship extends Blueprint {
/// {@macro android_spaceship}
AndroidSpaceship({required Vector2 position}) AndroidSpaceship({required Vector2 position})
: super( : super(
components: [ components: [
@ -29,9 +27,6 @@ class AndroidSpaceship extends Blueprint {
)..initialPosition = position - Vector2(-7.5, -1.1), )..initialPosition = position - Vector2(-7.5, -1.1),
], ],
); );
/// Total size of the spaceship.
static final size = Vector2(25.8, 19.8);
} }
class _SpaceshipSaucer extends BodyComponent with InitialPosition, Layered { class _SpaceshipSaucer extends BodyComponent with InitialPosition, Layered {
@ -42,22 +37,20 @@ class _SpaceshipSaucer extends BodyComponent with InitialPosition, Layered {
@override @override
Body createBody() { Body createBody() {
final shape = _SpaceshipSaucerShape(); final shape = _SpaceshipSaucerShape();
final fixtureDef = FixtureDef(shape);
final bodyDef = BodyDef( final bodyDef = BodyDef(
position: initialPosition, position: initialPosition,
userData: this, userData: this,
angle: -1.7, angle: -1.7,
); );
return world.createBody(bodyDef)..createFixture(fixtureDef); return world.createBody(bodyDef)..createFixtureFromShape(shape);
} }
} }
class _SpaceshipSaucerShape extends ChainShape { class _SpaceshipSaucerShape extends ChainShape {
_SpaceshipSaucerShape() { _SpaceshipSaucerShape() {
final minorRadius = (AndroidSpaceship.size.y - 2.3) / 2; const minorRadius = 9.75;
final majorRadius = (AndroidSpaceship.size.x - 2) / 2; const majorRadius = 11.9;
createChain( createChain(
[ [
@ -150,10 +143,7 @@ class _AndroidHead extends BodyComponent with InitialPosition, Layered {
shape, shape,
restitution: 0.1, restitution: 0.1,
); );
final bodyDef = BodyDef( final bodyDef = BodyDef(position: initialPosition);
position: initialPosition,
userData: this,
);
return world.createBody(bodyDef)..createFixture(fixtureDef); return world.createBody(bodyDef)..createFixture(fixtureDef);
} }

Loading…
Cancel
Save