diff --git a/lib/game/components/board.dart b/lib/game/components/board.dart index f7b80bd8..dcd4e66e 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, [SlingShot]s are arranged. +/// [RoundBumper]s, [Kicker]s are arranged. /// {entemplate} class Board extends Component { /// {@macro board} @@ -76,7 +76,7 @@ class _FlutterForest extends Component { /// {@template bottom_group} /// Grouping of the board's bottom [Component]s. /// -/// The [_BottomGroup] consists of[Flipper]s, [Baseboard]s and [SlingShot]s. +/// The [_BottomGroup] consists of[Flipper]s, [Baseboard]s and [Kicker]s. /// {@endtemplate} // TODO(alestiago): Consider renaming once entire Board is defined. class _BottomGroup extends Component { @@ -138,14 +138,14 @@ class _BottomGroupSide extends Component { (Flipper.width * direction) - direction, Flipper.height, ); - final slingShot = SlingShot( + final kicker = Kicker( side: _side, )..initialPosition = _position + Vector2( (Flipper.width) * direction, - Flipper.height + SlingShot.size.y, + Flipper.height + Kicker.size.y, ); - await addAll([flipper, baseboard, slingShot]); + await addAll([flipper, baseboard, kicker]); } } diff --git a/lib/game/components/board_side.dart b/lib/game/components/board_side.dart index f7587f47..2ef8d651 100644 --- a/lib/game/components/board_side.dart +++ b/lib/game/components/board_side.dart @@ -3,7 +3,7 @@ import 'package:pinball/game/game.dart'; /// Indicates a side of the board. /// /// Usually used to position or mirror elements of a [PinballGame]; such as a -/// [Flipper] or [SlingShot]. +/// [Flipper] or [Kicker]. enum BoardSide { /// The left side of the board. left, diff --git a/lib/game/components/components.dart b/lib/game/components/components.dart index 84525166..a255e652 100644 --- a/lib/game/components/components.dart +++ b/lib/game/components/components.dart @@ -7,6 +7,7 @@ export 'flipper.dart'; export 'initial_position.dart'; export 'jetpack_ramp.dart'; export 'joint_anchor.dart'; +export 'kicker.dart'; export 'launcher_ramp.dart'; export 'layer.dart'; export 'pathway.dart'; @@ -14,6 +15,5 @@ export 'plunger.dart'; export 'ramp_opening.dart'; export 'round_bumper.dart'; export 'score_points.dart'; -export 'sling_shot.dart'; export 'spaceship.dart'; export 'wall.dart'; diff --git a/lib/game/components/sling_shot.dart b/lib/game/components/kicker.dart similarity index 88% rename from lib/game/components/sling_shot.dart rename to lib/game/components/kicker.dart index 53160213..87e0332f 100644 --- a/lib/game/components/sling_shot.dart +++ b/lib/game/components/kicker.dart @@ -10,11 +10,11 @@ import 'package:pinball/game/game.dart'; /// Triangular [BodyType.static] body that propels the [Ball] towards the /// opposite side. /// -/// [SlingShot]s are usually positioned above each [Flipper]. +/// [Kicker]s are usually positioned above each [Flipper]. /// {@endtemplate sling_shot} -class SlingShot extends BodyComponent with InitialPosition { +class Kicker extends BodyComponent with InitialPosition { /// {@macro sling_shot} - SlingShot({ + Kicker({ required BoardSide side, }) : _side = side { // TODO(alestiago): Use sprite instead of color when provided. @@ -23,14 +23,14 @@ class SlingShot extends BodyComponent with InitialPosition { ..style = PaintingStyle.fill; } - /// Whether the [SlingShot] is on the left or right side of the board. + /// Whether the [Kicker] is on the left or right side of the board. /// - /// A [SlingShot] with [BoardSide.left] propels the [Ball] to the right, - /// whereas a [SlingShot] with [BoardSide.right] propels the [Ball] to the + /// A [Kicker] with [BoardSide.left] propels the [Ball] to the right, + /// whereas a [Kicker] with [BoardSide.right] propels the [Ball] to the /// left. final BoardSide _side; - /// The size of the [SlingShot] body. + /// The size of the [Kicker] body. // TODO(alestiago): Use size from PositionedBodyComponent instead, // once a sprite is given. static final Vector2 size = Vector2(4, 10); @@ -78,7 +78,7 @@ class SlingShot extends BodyComponent with InitialPosition { final bottomLineFixtureDef = FixtureDef(bottomEdge)..friction = 0; fixturesDefs.add(bottomLineFixtureDef); - final kickerEdge = EdgeShape() + final bouncyEdge = EdgeShape() ..set( upperCircle.position + Vector2( @@ -92,11 +92,11 @@ class SlingShot extends BodyComponent with InitialPosition { ), ); - final kickerFixtureDef = FixtureDef(kickerEdge) + final boncyFixtureDef = FixtureDef(bouncyEdge) // TODO(alestiago): Play with restitution value once game is bundled. ..restitution = 10.0 ..friction = 0; - fixturesDefs.add(kickerFixtureDef); + fixturesDefs.add(boncyFixtureDef); // TODO(alestiago): Evaluate if there is value on centering the fixtures. final centroid = geometry.centroid( diff --git a/test/game/components/board_test.dart b/test/game/components/board_test.dart index ccf599ec..1b87fd24 100644 --- a/test/game/components/board_test.dart +++ b/test/game/components/board_test.dart @@ -65,14 +65,14 @@ void main() { ); flameTester.test( - 'has two SlingShots', + 'has two Kickers', (game) async { final board = Board(size: Vector2.all(500)); await game.ready(); await game.ensureAdd(board); - final slingShots = board.findNestedChildren(); - expect(slingShots.length, equals(2)); + final kickers = board.findNestedChildren(); + expect(kickers.length, equals(2)); }, ); diff --git a/test/game/components/sling_shot_test.dart b/test/game/components/kicker_test.dart similarity index 65% rename from test/game/components/sling_shot_test.dart rename to test/game/components/kicker_test.dart index 2bfb2355..211ff8ad 100644 --- a/test/game/components/sling_shot_test.dart +++ b/test/game/components/kicker_test.dart @@ -6,43 +6,43 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:pinball/game/game.dart'; void main() { - group('SlingShot', () { + group('Kicker', () { // TODO(alestiago): Include golden tests for left and right. final flameTester = FlameTester(Forge2DGame.new); flameTester.test( 'loads correctly', (game) async { - final slingShot = SlingShot( + final kicker = Kicker( side: BoardSide.left, ); - await game.ensureAdd(slingShot); + await game.ensureAdd(kicker); - expect(game.contains(slingShot), isTrue); + expect(game.contains(kicker), isTrue); }, ); flameTester.test( 'body is static', (game) async { - final slingShot = SlingShot( + final kicker = Kicker( side: BoardSide.left, ); - await game.ensureAdd(slingShot); + await game.ensureAdd(kicker); - expect(slingShot.body.bodyType, equals(BodyType.static)); + expect(kicker.body.bodyType, equals(BodyType.static)); }, ); flameTester.test( 'has restitution', (game) async { - final slingShot = SlingShot( + final kicker = Kicker( side: BoardSide.left, ); - await game.ensureAdd(slingShot); + await game.ensureAdd(kicker); - final totalRestitution = slingShot.body.fixtures.fold( + final totalRestitution = kicker.body.fixtures.fold( 0, (total, fixture) => total + fixture.restitution, ); @@ -53,12 +53,12 @@ void main() { flameTester.test( 'has no friction', (game) async { - final slingShot = SlingShot( + final kicker = Kicker( side: BoardSide.left, ); - await game.ensureAdd(slingShot); + await game.ensureAdd(kicker); - final totalFriction = slingShot.body.fixtures.fold( + final totalFriction = kicker.body.fixtures.fold( 0, (total, fixture) => total + fixture.friction, );