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 {
/// {@macro ball}
Ball({
Color? baseColor,
String? spriteAsset,
}) : super(
renderBody: false,

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save