From b02070c941dc4715ec4e26129bb4e0308744a1c4 Mon Sep 17 00:00:00 2001 From: alestiago Date: Thu, 24 Mar 2022 11:19:29 +0000 Subject: [PATCH] refactor: rename RoundBumper to DashNestBumper --- lib/game/components/board.dart | 10 +++++----- lib/game/components/round_bumper.dart | 13 ++++++------- test/game/components/board_test.dart | 2 +- test/game/components/round_bumper_test.dart | 12 ++++++------ 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/lib/game/components/board.dart b/lib/game/components/board.dart index af03efdd..a3ae6963 100644 --- a/lib/game/components/board.dart +++ b/lib/game/components/board.dart @@ -3,7 +3,7 @@ import 'package:pinball/game/game.dart'; /// {@template board} /// The main flat surface of the [PinballGame], where the [Flipper]s, -/// [RoundBumper]s, [Kicker]s are arranged. +/// [DashNestBumper]s, [Kicker]s are arranged. /// {entemplate} class Board extends Component { /// {@macro board} @@ -36,7 +36,7 @@ class Board extends Component { /// {@template flutter_forest} /// Area positioned at the top right of the [Board] where the [Ball] -/// can bounce off [RoundBumper]s. +/// can bounce off [DashNestBumper]s. /// {@endtemplate} class _FlutterForest extends Component { /// {@macro flutter_forest} @@ -50,15 +50,15 @@ class _FlutterForest extends Component { Future onLoad() async { // TODO(alestiago): adjust positioning once sprites are added. // TODO(alestiago): Use [NestBumper] instead of [RoundBumper] once provided. - final smallLeftNest = RoundBumper( + final smallLeftNest = DashNestBumper( radius: 1, points: 10, )..initialPosition = position + Vector2(-4.8, 2.8); - final smallRightNest = RoundBumper( + final smallRightNest = DashNestBumper( radius: 1, points: 10, )..initialPosition = position + Vector2(0.5, -5.5); - final bigNest = RoundBumper( + final bigNest = DashNestBumper( radius: 2, points: 20, )..initialPosition = position; diff --git a/lib/game/components/round_bumper.dart b/lib/game/components/round_bumper.dart index 2f43a35b..da3504ff 100644 --- a/lib/game/components/round_bumper.dart +++ b/lib/game/components/round_bumper.dart @@ -1,21 +1,21 @@ import 'package:flame_forge2d/flame_forge2d.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. /// {@endtemplate} -class RoundBumper extends BodyComponent with ScorePoints, InitialPosition { - /// {@macro round_bumper} - RoundBumper({ +class DashNestBumper extends BodyComponent with ScorePoints, InitialPosition { + /// {@macro dash_nest_bumper} + DashNestBumper({ required double radius, required int points, }) : _radius = radius, _points = points; - /// The radius of the [RoundBumper]. + /// The radius of the [DashNestBumper]. final double _radius; - /// Points awarded from hitting this [RoundBumper]. + /// Points awarded from hitting this [DashNestBumper]. final int _points; @override @@ -24,7 +24,6 @@ class RoundBumper extends BodyComponent with ScorePoints, InitialPosition { @override Body createBody() { final shape = CircleShape()..radius = _radius; - final fixtureDef = FixtureDef(shape)..restitution = 1; final bodyDef = BodyDef()..position = initialPosition; diff --git a/test/game/components/board_test.dart b/test/game/components/board_test.dart index f0cd0e16..0ea7c50a 100644 --- a/test/game/components/board_test.dart +++ b/test/game/components/board_test.dart @@ -82,7 +82,7 @@ void main() { await game.ready(); await game.ensureAdd(board); - final roundBumpers = board.descendants().whereType(); + final roundBumpers = board.descendants().whereType(); expect(roundBumpers.length, equals(3)); }, ); diff --git a/test/game/components/round_bumper_test.dart b/test/game/components/round_bumper_test.dart index 437167ad..f625e8cf 100644 --- a/test/game/components/round_bumper_test.dart +++ b/test/game/components/round_bumper_test.dart @@ -17,7 +17,7 @@ void main() { 'loads correctly', (game) async { await game.ready(); - final roundBumper = RoundBumper( + final roundBumper = DashNestBumper( radius: radius, points: points, ); @@ -30,7 +30,7 @@ void main() { flameTester.test( 'has points', (game) async { - final roundBumper = RoundBumper( + final roundBumper = DashNestBumper( radius: radius, points: points, ); @@ -44,7 +44,7 @@ void main() { flameTester.test( 'is static', (game) async { - final roundBumper = RoundBumper( + final roundBumper = DashNestBumper( radius: radius, points: points, ); @@ -59,7 +59,7 @@ void main() { flameTester.test( 'exists', (game) async { - final roundBumper = RoundBumper( + final roundBumper = DashNestBumper( radius: radius, points: points, ); @@ -72,7 +72,7 @@ void main() { flameTester.test( 'has restitution', (game) async { - final roundBumper = RoundBumper( + final roundBumper = DashNestBumper( radius: radius, points: points, ); @@ -86,7 +86,7 @@ void main() { flameTester.test( 'shape is circular', (game) async { - final roundBumper = RoundBumper( + final roundBumper = DashNestBumper( radius: radius, points: points, );