refactor: rename RoundBumper to DashNestBumper

pull/89/head
alestiago 4 years ago
parent baab7f65c4
commit b02070c941

@ -3,7 +3,7 @@ import 'package:pinball/game/game.dart';
/// {@template board} /// {@template board}
/// The main flat surface of the [PinballGame], where the [Flipper]s, /// The main flat surface of the [PinballGame], where the [Flipper]s,
/// [RoundBumper]s, [Kicker]s are arranged. /// [DashNestBumper]s, [Kicker]s are arranged.
/// {entemplate} /// {entemplate}
class Board extends Component { class Board extends Component {
/// {@macro board} /// {@macro board}
@ -36,7 +36,7 @@ class Board extends Component {
/// {@template flutter_forest} /// {@template flutter_forest}
/// Area positioned at the top right of the [Board] where the [Ball] /// Area positioned at the top right of the [Board] where the [Ball]
/// can bounce off [RoundBumper]s. /// can bounce off [DashNestBumper]s.
/// {@endtemplate} /// {@endtemplate}
class _FlutterForest extends Component { class _FlutterForest extends Component {
/// {@macro flutter_forest} /// {@macro flutter_forest}
@ -50,15 +50,15 @@ class _FlutterForest extends Component {
Future<void> onLoad() async { Future<void> onLoad() async {
// TODO(alestiago): adjust positioning once sprites are added. // TODO(alestiago): adjust positioning once sprites are added.
// TODO(alestiago): Use [NestBumper] instead of [RoundBumper] once provided. // TODO(alestiago): Use [NestBumper] instead of [RoundBumper] once provided.
final smallLeftNest = RoundBumper( final smallLeftNest = DashNestBumper(
radius: 1, radius: 1,
points: 10, points: 10,
)..initialPosition = position + Vector2(-4.8, 2.8); )..initialPosition = position + Vector2(-4.8, 2.8);
final smallRightNest = RoundBumper( final smallRightNest = DashNestBumper(
radius: 1, radius: 1,
points: 10, points: 10,
)..initialPosition = position + Vector2(0.5, -5.5); )..initialPosition = position + Vector2(0.5, -5.5);
final bigNest = RoundBumper( final bigNest = DashNestBumper(
radius: 2, radius: 2,
points: 20, points: 20,
)..initialPosition = position; )..initialPosition = position;

@ -1,21 +1,21 @@
import 'package:flame_forge2d/flame_forge2d.dart'; import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:pinball/game/game.dart'; import 'package:pinball/game/game.dart';
/// {@template round_bumper} /// {@template dash_nest_bumper}
/// Circular body that repels a [Ball] on contact, increasing the score. /// Circular body that repels a [Ball] on contact, increasing the score.
/// {@endtemplate} /// {@endtemplate}
class RoundBumper extends BodyComponent with ScorePoints, InitialPosition { class DashNestBumper extends BodyComponent with ScorePoints, InitialPosition {
/// {@macro round_bumper} /// {@macro dash_nest_bumper}
RoundBumper({ DashNestBumper({
required double radius, required double radius,
required int points, required int points,
}) : _radius = radius, }) : _radius = radius,
_points = points; _points = points;
/// The radius of the [RoundBumper]. /// The radius of the [DashNestBumper].
final double _radius; final double _radius;
/// Points awarded from hitting this [RoundBumper]. /// Points awarded from hitting this [DashNestBumper].
final int _points; final int _points;
@override @override
@ -24,7 +24,6 @@ class RoundBumper extends BodyComponent with ScorePoints, InitialPosition {
@override @override
Body createBody() { Body createBody() {
final shape = CircleShape()..radius = _radius; final shape = CircleShape()..radius = _radius;
final fixtureDef = FixtureDef(shape)..restitution = 1; final fixtureDef = FixtureDef(shape)..restitution = 1;
final bodyDef = BodyDef()..position = initialPosition; final bodyDef = BodyDef()..position = initialPosition;

@ -82,7 +82,7 @@ void main() {
await game.ready(); await game.ready();
await game.ensureAdd(board); await game.ensureAdd(board);
final roundBumpers = board.descendants().whereType<RoundBumper>(); final roundBumpers = board.descendants().whereType<DashNestBumper>();
expect(roundBumpers.length, equals(3)); expect(roundBumpers.length, equals(3));
}, },
); );

@ -17,7 +17,7 @@ void main() {
'loads correctly', 'loads correctly',
(game) async { (game) async {
await game.ready(); await game.ready();
final roundBumper = RoundBumper( final roundBumper = DashNestBumper(
radius: radius, radius: radius,
points: points, points: points,
); );
@ -30,7 +30,7 @@ void main() {
flameTester.test( flameTester.test(
'has points', 'has points',
(game) async { (game) async {
final roundBumper = RoundBumper( final roundBumper = DashNestBumper(
radius: radius, radius: radius,
points: points, points: points,
); );
@ -44,7 +44,7 @@ void main() {
flameTester.test( flameTester.test(
'is static', 'is static',
(game) async { (game) async {
final roundBumper = RoundBumper( final roundBumper = DashNestBumper(
radius: radius, radius: radius,
points: points, points: points,
); );
@ -59,7 +59,7 @@ void main() {
flameTester.test( flameTester.test(
'exists', 'exists',
(game) async { (game) async {
final roundBumper = RoundBumper( final roundBumper = DashNestBumper(
radius: radius, radius: radius,
points: points, points: points,
); );
@ -72,7 +72,7 @@ void main() {
flameTester.test( flameTester.test(
'has restitution', 'has restitution',
(game) async { (game) async {
final roundBumper = RoundBumper( final roundBumper = DashNestBumper(
radius: radius, radius: radius,
points: points, points: points,
); );
@ -86,7 +86,7 @@ void main() {
flameTester.test( flameTester.test(
'shape is circular', 'shape is circular',
(game) async { (game) async {
final roundBumper = RoundBumper( final roundBumper = DashNestBumper(
radius: radius, radius: radius,
points: points, points: points,
); );

Loading…
Cancel
Save