refactor: removed all baseColor for ball

pull/279/head
RuiAlonso 3 years ago
parent 73274e56c7
commit 6e89faedee

@ -14,7 +14,6 @@ class Ball<T extends Forge2DGame> extends BodyComponent<T>
with Layered, InitialPosition, ZIndex { with Layered, InitialPosition, ZIndex {
/// {@macro ball} /// {@macro ball}
Ball({ Ball({
Color? baseColor,
String? spriteAsset, String? spriteAsset,
}) : super( }) : super(
renderBody: false, renderBody: false,

@ -7,7 +7,6 @@ import 'package:sandbox/stories/ball/basic_ball_game.dart';
class AndroidBumperAGame extends BallGame { class AndroidBumperAGame extends BallGame {
AndroidBumperAGame() AndroidBumperAGame()
: super( : super(
color: const Color(0xFF0000FF),
imagesFileNames: [ imagesFileNames: [
Assets.images.android.bumper.a.lit.keyName, Assets.images.android.bumper.a.lit.keyName,
Assets.images.android.bumper.a.dimmed.keyName, Assets.images.android.bumper.a.dimmed.keyName,

@ -7,7 +7,6 @@ import 'package:sandbox/stories/ball/basic_ball_game.dart';
class AndroidBumperBGame extends BallGame { class AndroidBumperBGame extends BallGame {
AndroidBumperBGame() AndroidBumperBGame()
: super( : super(
color: const Color(0xFF0000FF),
imagesFileNames: [ imagesFileNames: [
Assets.images.android.bumper.b.lit.keyName, Assets.images.android.bumper.b.lit.keyName,
Assets.images.android.bumper.b.dimmed.keyName, Assets.images.android.bumper.b.dimmed.keyName,

@ -1,14 +1,12 @@
import 'dart:async'; import 'dart:async';
import 'package:flame/input.dart'; import 'package:flame/input.dart';
import 'package:flutter/material.dart';
import 'package:pinball_components/pinball_components.dart'; import 'package:pinball_components/pinball_components.dart';
import 'package:sandbox/stories/ball/basic_ball_game.dart'; import 'package:sandbox/stories/ball/basic_ball_game.dart';
class SpaceshipRailGame extends BallGame { class SpaceshipRailGame extends BallGame {
SpaceshipRailGame() SpaceshipRailGame()
: super( : super(
color: Colors.blue,
ballPriority: ZIndexes.ballOnSpaceshipRail, ballPriority: ZIndexes.ballOnSpaceshipRail,
ballLayer: Layer.spaceshipExitRail, ballLayer: Layer.spaceshipExitRail,
imagesFileNames: [ imagesFileNames: [

@ -9,7 +9,6 @@ import 'package:sandbox/stories/ball/basic_ball_game.dart';
class SpaceshipRampGame extends BallGame with KeyboardEvents { class SpaceshipRampGame extends BallGame with KeyboardEvents {
SpaceshipRampGame() SpaceshipRampGame()
: super( : super(
color: Colors.blue,
ballPriority: ZIndexes.ballOnSpaceshipRamp, ballPriority: ZIndexes.ballOnSpaceshipRamp,
ballLayer: Layer.spaceshipEntranceRamp, ballLayer: Layer.spaceshipEntranceRamp,
imagesFileNames: [ imagesFileNames: [

@ -1,5 +1,4 @@
import 'package:flame/components.dart'; import 'package:flame/components.dart';
import 'package:flutter/material.dart';
import 'package:pinball_components/pinball_components.dart'; import 'package:pinball_components/pinball_components.dart';
import 'package:pinball_theme/pinball_theme.dart' as theme; import 'package:pinball_theme/pinball_theme.dart' as theme;
import 'package:sandbox/common/common.dart'; import 'package:sandbox/common/common.dart';
@ -25,7 +24,7 @@ class BallBoosterGame extends LineGame {
@override @override
void onLine(Vector2 line) { void onLine(Vector2 line) {
final ball = Ball(baseColor: Colors.transparent); final ball = Ball();
add(ball); add(ball);
ball.mounted.then((value) => ball.boost(line * -1 * 20)); ball.mounted.then((value) => ball.boost(line * -1 * 20));

@ -1,12 +1,10 @@
import 'package:flame/input.dart'; import 'package:flame/input.dart';
import 'package:flutter/material.dart';
import 'package:pinball_components/pinball_components.dart'; import 'package:pinball_components/pinball_components.dart';
import 'package:pinball_theme/pinball_theme.dart' as theme; import 'package:pinball_theme/pinball_theme.dart' as theme;
import 'package:sandbox/common/common.dart'; import 'package:sandbox/common/common.dart';
class BallGame extends AssetsGame with TapDetector, Traceable { class BallGame extends AssetsGame with TapDetector, Traceable {
BallGame({ BallGame({
Color? color,
this.ballPriority = 0, this.ballPriority = 0,
this.ballLayer = Layer.all, this.ballLayer = Layer.all,
this.character, this.character,

@ -1,12 +1,11 @@
import 'dart:ui'; import 'dart:ui';
import 'package:flame_forge2d/flame_forge2d.dart'; import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:flutter/material.dart';
import 'package:pinball_components/pinball_components.dart'; import 'package:pinball_components/pinball_components.dart';
import 'package:sandbox/stories/ball/basic_ball_game.dart'; import 'package:sandbox/stories/ball/basic_ball_game.dart';
class GoogleLetterGame extends BallGame { class GoogleLetterGame extends BallGame {
GoogleLetterGame() : super(color: const Color(0xFF009900)); GoogleLetterGame() : super();
static const description = ''' static const description = '''
Shows how a GoogleLetter is rendered. Shows how a GoogleLetter is rendered.

@ -1,14 +1,12 @@
import 'dart:async'; import 'dart:async';
import 'package:flame/input.dart'; import 'package:flame/input.dart';
import 'package:flutter/material.dart';
import 'package:pinball_components/pinball_components.dart'; import 'package:pinball_components/pinball_components.dart';
import 'package:sandbox/stories/ball/basic_ball_game.dart'; import 'package:sandbox/stories/ball/basic_ball_game.dart';
class LaunchRampGame extends BallGame { class LaunchRampGame extends BallGame {
LaunchRampGame() LaunchRampGame()
: super( : super(
color: Colors.blue,
ballPriority: ZIndexes.ballOnLaunchRamp, ballPriority: ZIndexes.ballOnLaunchRamp,
ballLayer: Layer.launcher, ballLayer: Layer.launcher,
); );

@ -6,7 +6,7 @@ import 'package:sandbox/common/common.dart';
import 'package:sandbox/stories/ball/basic_ball_game.dart'; import 'package:sandbox/stories/ball/basic_ball_game.dart';
class PlungerGame extends BallGame with KeyboardEvents, Traceable { class PlungerGame extends BallGame with KeyboardEvents, Traceable {
PlungerGame() : super(color: const Color(0xFFFF0000)); PlungerGame() : super();
static const description = ''' static const description = '''
Shows how Plunger is rendered. Shows how Plunger is rendered.

@ -17,7 +17,7 @@ void main() {
flameTester.test( flameTester.test(
'loads correctly', 'loads correctly',
(game) async { (game) async {
final ball = Ball(baseColor: Colors.blue); final ball = Ball();
await game.ready(); await game.ready();
await game.ensureAdd(ball); await game.ensureAdd(ball);
@ -29,7 +29,7 @@ void main() {
flameTester.test( flameTester.test(
'is dynamic', 'is dynamic',
(game) async { (game) async {
final ball = Ball(baseColor: Colors.blue); final ball = Ball();
await game.ensureAdd(ball); await game.ensureAdd(ball);
expect(ball.body.bodyType, equals(BodyType.dynamic)); expect(ball.body.bodyType, equals(BodyType.dynamic));
@ -38,7 +38,7 @@ void main() {
group('can be moved', () { group('can be moved', () {
flameTester.test('by its weight', (game) async { flameTester.test('by its weight', (game) async {
final ball = Ball(baseColor: Colors.blue); final ball = Ball();
await game.ensureAdd(ball); await game.ensureAdd(ball);
game.update(1); game.update(1);
@ -46,7 +46,7 @@ void main() {
}); });
flameTester.test('by applying velocity', (game) async { flameTester.test('by applying velocity', (game) async {
final ball = Ball(baseColor: Colors.blue); final ball = Ball();
await game.ensureAdd(ball); await game.ensureAdd(ball);
ball.body.gravityScale = Vector2.zero(); ball.body.gravityScale = Vector2.zero();
@ -61,7 +61,7 @@ void main() {
flameTester.test( flameTester.test(
'exists', 'exists',
(game) async { (game) async {
final ball = Ball(baseColor: Colors.blue); final ball = Ball();
await game.ensureAdd(ball); await game.ensureAdd(ball);
expect(ball.body.fixtures[0], isA<Fixture>()); expect(ball.body.fixtures[0], isA<Fixture>());
@ -71,7 +71,7 @@ void main() {
flameTester.test( flameTester.test(
'is dense', 'is dense',
(game) async { (game) async {
final ball = Ball(baseColor: Colors.blue); final ball = Ball();
await game.ensureAdd(ball); await game.ensureAdd(ball);
final fixture = ball.body.fixtures[0]; final fixture = ball.body.fixtures[0];
@ -82,7 +82,7 @@ void main() {
flameTester.test( flameTester.test(
'shape is circular', 'shape is circular',
(game) async { (game) async {
final ball = Ball(baseColor: Colors.blue); final ball = Ball();
await game.ensureAdd(ball); await game.ensureAdd(ball);
final fixture = ball.body.fixtures[0]; final fixture = ball.body.fixtures[0];
@ -94,7 +94,7 @@ void main() {
flameTester.test( flameTester.test(
'has Layer.all as default filter maskBits', 'has Layer.all as default filter maskBits',
(game) async { (game) async {
final ball = Ball(baseColor: Colors.blue); final ball = Ball();
await game.ready(); await game.ready();
await game.ensureAdd(ball); await game.ensureAdd(ball);
await game.ready(); await game.ready();
@ -108,7 +108,7 @@ void main() {
group('stop', () { group('stop', () {
group("can't be moved", () { group("can't be moved", () {
flameTester.test('by its weight', (game) async { flameTester.test('by its weight', (game) async {
final ball = Ball(baseColor: Colors.blue); final ball = Ball();
await game.ensureAdd(ball); await game.ensureAdd(ball);
ball.stop(); ball.stop();
@ -121,7 +121,7 @@ void main() {
// to prevent forces on a ball while stopped. // to prevent forces on a ball while stopped.
// flameTester.test('by applying velocity', (game) async { // flameTester.test('by applying velocity', (game) async {
// final ball = Ball(baseColor: Colors.blue); // final ball = Ball();
// await game.ensureAdd(ball); // await game.ensureAdd(ball);
// ball.stop(); // ball.stop();
@ -136,7 +136,7 @@ void main() {
flameTester.test( flameTester.test(
'by its weight when previously stopped', 'by its weight when previously stopped',
(game) async { (game) async {
final ball = Ball(baseColor: Colors.blue); final ball = Ball();
await game.ensureAdd(ball); await game.ensureAdd(ball);
ball.stop(); ball.stop();
ball.resume(); ball.resume();
@ -149,7 +149,7 @@ void main() {
flameTester.test( flameTester.test(
'by applying velocity when previously stopped', 'by applying velocity when previously stopped',
(game) async { (game) async {
final ball = Ball(baseColor: Colors.blue); final ball = Ball();
await game.ensureAdd(ball); await game.ensureAdd(ball);
ball.stop(); ball.stop();
ball.resume(); ball.resume();
@ -165,7 +165,7 @@ void main() {
group('boost', () { group('boost', () {
flameTester.test('applies an impulse to the ball', (game) async { flameTester.test('applies an impulse to the ball', (game) async {
final ball = Ball(baseColor: Colors.blue); final ball = Ball();
await game.ensureAdd(ball); await game.ensureAdd(ball);
expect(ball.body.linearVelocity, equals(Vector2.zero())); expect(ball.body.linearVelocity, equals(Vector2.zero()));
@ -176,7 +176,7 @@ void main() {
}); });
flameTester.test('adds TurboChargeSpriteAnimation', (game) async { flameTester.test('adds TurboChargeSpriteAnimation', (game) async {
final ball = Ball(baseColor: Colors.blue); final ball = Ball();
await game.ensureAdd(ball); await game.ensureAdd(ball);
await ball.boost(Vector2.all(10)); await ball.boost(Vector2.all(10));
@ -190,7 +190,7 @@ void main() {
flameTester.test('removes TurboChargeSpriteAnimation after it finishes', flameTester.test('removes TurboChargeSpriteAnimation after it finishes',
(game) async { (game) async {
final ball = Ball(baseColor: Colors.blue); final ball = Ball();
await game.ensureAdd(ball); await game.ensureAdd(ball);
await ball.boost(Vector2.all(10)); await ball.boost(Vector2.all(10));

@ -28,7 +28,7 @@ void main() {
flameTester.test( flameTester.test(
'beginContact sets ball sprite to be invisible and calls onChomp', 'beginContact sets ball sprite to be invisible and calls onChomp',
(game) async { (game) async {
final ball = Ball(baseColor: Colors.red); final ball = Ball();
final behavior = ChromeDinoChompingBehavior(); final behavior = ChromeDinoChompingBehavior();
final bloc = MockChromeDinoCubit(); final bloc = MockChromeDinoCubit();
whenListen( whenListen(

@ -31,7 +31,7 @@ void main() {
flameTester.test( flameTester.test(
'sets ball sprite to visible and sets a linear velocity', 'sets ball sprite to visible and sets a linear velocity',
(game) async { (game) async {
final ball = Ball(baseColor: Colors.red); final ball = Ball();
final behavior = ChromeDinoSpittingBehavior(); final behavior = ChromeDinoSpittingBehavior();
final bloc = MockChromeDinoCubit(); final bloc = MockChromeDinoCubit();
final streamController = StreamController<ChromeDinoState>(); final streamController = StreamController<ChromeDinoState>();
@ -69,7 +69,7 @@ void main() {
flameTester.test( flameTester.test(
'calls onSpit', 'calls onSpit',
(game) async { (game) async {
final ball = Ball(baseColor: Colors.red); final ball = Ball();
final behavior = ChromeDinoSpittingBehavior(); final behavior = ChromeDinoSpittingBehavior();
final bloc = MockChromeDinoCubit(); final bloc = MockChromeDinoCubit();
final streamController = StreamController<ChromeDinoState>(); final streamController = StreamController<ChromeDinoState>();

@ -7,7 +7,7 @@ void main() {
group( group(
'ChromeDinoCubit', 'ChromeDinoCubit',
() { () {
final ball = Ball(baseColor: Colors.red); final ball = Ball();
blocTest<ChromeDinoCubit, ChromeDinoState>( blocTest<ChromeDinoCubit, ChromeDinoState>(
'onOpenMouth emits true', 'onOpenMouth emits true',

@ -61,7 +61,7 @@ void main() {
'copies correctly ' 'copies correctly '
'when all arguments specified', 'when all arguments specified',
() { () {
final ball = Ball(baseColor: Colors.red); final ball = Ball();
const chromeDinoState = ChromeDinoState( const chromeDinoState = ChromeDinoState(
status: ChromeDinoStatus.chomping, status: ChromeDinoStatus.chomping,
isMouthOpen: true, isMouthOpen: true,

@ -89,7 +89,7 @@ void main() {
'has greater mass than Ball', 'has greater mass than Ball',
(game) async { (game) async {
final flipper = Flipper(side: BoardSide.left); final flipper = Flipper(side: BoardSide.left);
final ball = Ball(baseColor: Colors.white); final ball = Ball();
await game.ready(); await game.ready();
await game.ensureAddAll([flipper, ball]); await game.ensureAddAll([flipper, ball]);

@ -31,7 +31,7 @@ void main() {
late GameBloc gameBloc; late GameBloc gameBloc;
setUp(() { setUp(() {
ball = Ball(baseColor: const Color(0xFF00FFFF)); ball = Ball();
gameBloc = MockGameBloc(); gameBloc = MockGameBloc();
whenListen( whenListen(
gameBloc, gameBloc,
@ -60,7 +60,7 @@ void main() {
await ball.add(controller); await ball.add(controller);
await game.ensureAdd(ball); await game.ensureAdd(ball);
final otherBall = Ball(baseColor: const Color(0xFF00FFFF)); final otherBall = Ball();
final otherController = BallController(otherBall); final otherController = BallController(otherBall);
await otherBall.add(otherController); await otherBall.add(otherController);
await game.ensureAdd(otherBall); await game.ensureAdd(otherBall);

Loading…
Cancel
Save