@ -0,0 +1,18 @@
|
||||
name: share_repository
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- "packages/share_repository/**"
|
||||
- ".github/workflows/share_repository.yaml"
|
||||
|
||||
pull_request:
|
||||
paths:
|
||||
- "packages/share_repository/**"
|
||||
- ".github/workflows/share_repository.yaml"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/flutter_package.yml@v1
|
||||
with:
|
||||
working_directory: packages/share_repository
|
@ -1,52 +0,0 @@
|
||||
// ignore_for_file: avoid_renaming_method_parameters
|
||||
|
||||
import 'package:flame/components.dart';
|
||||
import 'package:flame_forge2d/flame_forge2d.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pinball/game/game.dart';
|
||||
import 'package:pinball_components/pinball_components.dart';
|
||||
import 'package:pinball_flame/pinball_flame.dart';
|
||||
|
||||
/// {@template controlled_sparky_computer}
|
||||
/// [SparkyComputer] with a [SparkyComputerController] attached.
|
||||
/// {@endtemplate}
|
||||
class ControlledSparkyComputer extends SparkyComputer
|
||||
with Controls<SparkyComputerController>, HasGameRef<Forge2DGame> {
|
||||
/// {@macro controlled_sparky_computer}
|
||||
ControlledSparkyComputer() : super() {
|
||||
controller = SparkyComputerController(this);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onLoad() async {
|
||||
await super.onLoad();
|
||||
gameRef.addContactCallback(SparkyComputerSensorBallContactCallback());
|
||||
}
|
||||
}
|
||||
|
||||
/// {@template sparky_computer_controller}
|
||||
/// Controller attached to a [SparkyComputer] that handles its game related
|
||||
/// logic.
|
||||
/// {@endtemplate}
|
||||
// TODO(allisonryan0002): listen for turbo charge game bonus and animate Sparky.
|
||||
class SparkyComputerController
|
||||
extends ComponentController<ControlledSparkyComputer> {
|
||||
/// {@macro sparky_computer_controller}
|
||||
SparkyComputerController(ControlledSparkyComputer controlledComputer)
|
||||
: super(controlledComputer);
|
||||
}
|
||||
|
||||
/// {@template sparky_computer_sensor_ball_contact_callback}
|
||||
/// Turbo charges the [Ball] when it enters the [SparkyComputer]
|
||||
/// {@endtemplate}
|
||||
@visibleForTesting
|
||||
class SparkyComputerSensorBallContactCallback
|
||||
extends ContactCallback<SparkyComputerSensor, ControlledBall> {
|
||||
/// {@macro sparky_computer_sensor_ball_contact_callback}
|
||||
SparkyComputerSensorBallContactCallback();
|
||||
|
||||
@override
|
||||
void begin(_, ControlledBall ball, __) {
|
||||
ball.controller.turboCharge();
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 365 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 7.1 KiB |
@ -0,0 +1,46 @@
|
||||
import 'package:flame/components.dart';
|
||||
import 'package:pinball_components/pinball_components.dart';
|
||||
|
||||
/// {@template sparky_animatronic}
|
||||
/// Animated Sparky that sits on top of the [SparkyComputer].
|
||||
/// {@endtemplate}
|
||||
class SparkyAnimatronic extends SpriteAnimationComponent with HasGameRef {
|
||||
/// {@macro sparky_animatronic}
|
||||
SparkyAnimatronic()
|
||||
: super(
|
||||
anchor: Anchor.center,
|
||||
playing: false,
|
||||
priority: RenderPriority.sparkyAnimatronic,
|
||||
);
|
||||
|
||||
@override
|
||||
Future<void> onLoad() async {
|
||||
await super.onLoad();
|
||||
|
||||
final spriteSheet = gameRef.images.fromCache(
|
||||
Assets.images.sparky.animatronic.keyName,
|
||||
);
|
||||
|
||||
const amountPerRow = 9;
|
||||
const amountPerColumn = 7;
|
||||
final textureSize = Vector2(
|
||||
spriteSheet.width / amountPerRow,
|
||||
spriteSheet.height / amountPerColumn,
|
||||
);
|
||||
size = textureSize / 10;
|
||||
|
||||
animation = SpriteAnimation.fromFrameData(
|
||||
spriteSheet,
|
||||
SpriteAnimationData.sequenced(
|
||||
amount: (amountPerRow * amountPerColumn) - 1,
|
||||
amountPerRow: amountPerRow,
|
||||
stepTime: 1 / 24,
|
||||
textureSize: textureSize,
|
||||
loop: false,
|
||||
),
|
||||
)..onComplete = () {
|
||||
animation?.reset();
|
||||
playing = false;
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
import 'package:dashbook/dashbook.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:sandbox/common/common.dart';
|
||||
|
||||
const _path =
|
||||
'https://github.com/VGVentures/pinball/tree/main/packages/pinball_components/sandbox/lib/stories/';
|
||||
|
||||
extension StoryAddGame on Story {
|
||||
void addGame({
|
||||
required String title,
|
||||
required String description,
|
||||
required Game Function(DashbookContext) gameBuilder,
|
||||
}) {
|
||||
final _chapter = Chapter(
|
||||
title,
|
||||
(DashbookContext context) {
|
||||
final game = gameBuilder(context);
|
||||
if (game is Traceable) {
|
||||
game.trace = context.boolProperty('Trace', true);
|
||||
}
|
||||
|
||||
return GameWidget(game: game);
|
||||
},
|
||||
this,
|
||||
codeLink: '$_path${name.toPath()}/${title.toPath()}',
|
||||
info: description,
|
||||
);
|
||||
chapters.add(_chapter);
|
||||
}
|
||||
}
|
||||
|
||||
extension on String {
|
||||
String toPath() {
|
||||
return replaceAll(' ', '_')..toLowerCase();
|
||||
}
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
export 'add_game.dart';
|
||||
export 'games.dart';
|
||||
export 'methods.dart';
|
||||
export 'trace.dart';
|
||||
|
@ -1,3 +0,0 @@
|
||||
String buildSourceLink(String path) {
|
||||
return 'https://github.com/VGVentures/pinball/tree/main/packages/pinball_components/sandbox/lib/stories/$path';
|
||||
}
|
@ -1,25 +1,36 @@
|
||||
import 'package:dashbook/dashbook.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:sandbox/common/common.dart';
|
||||
import 'package:sandbox/stories/alien_zone/alien_bumper_a_game.dart';
|
||||
import 'package:sandbox/stories/alien_zone/alien_bumper_b_game.dart';
|
||||
import 'package:sandbox/stories/alien_zone/spaceship_game.dart';
|
||||
import 'package:sandbox/stories/alien_zone/spaceship_rail_game.dart';
|
||||
import 'package:sandbox/stories/alien_zone/spaceship_ramp_game.dart';
|
||||
|
||||
void addAlienZoneStories(Dashbook dashbook) {
|
||||
dashbook.storiesOf('Alien Zone')
|
||||
..add(
|
||||
'Alien Bumper A',
|
||||
(context) => GameWidget(
|
||||
game: AlienBumperAGame()..trace = context.boolProperty('Trace', true),
|
||||
),
|
||||
codeLink: buildSourceLink('alien_zone/alien_bumper_a.dart'),
|
||||
info: AlienBumperAGame.info,
|
||||
..addGame(
|
||||
title: 'Alien Bumper A',
|
||||
description: AlienBumperAGame.description,
|
||||
gameBuilder: (_) => AlienBumperAGame(),
|
||||
)
|
||||
..add(
|
||||
'Alien Bumper B',
|
||||
(context) => GameWidget(
|
||||
game: AlienBumperBGame()..trace = context.boolProperty('Trace', true),
|
||||
),
|
||||
codeLink: buildSourceLink('alien_zone/alien_bumper_b.dart'),
|
||||
info: AlienBumperAGame.info,
|
||||
..addGame(
|
||||
title: 'Alien Bumper B',
|
||||
description: AlienBumperBGame.description,
|
||||
gameBuilder: (_) => AlienBumperBGame(),
|
||||
)
|
||||
..addGame(
|
||||
title: 'Spaceship',
|
||||
description: SpaceshipGame.description,
|
||||
gameBuilder: (_) => SpaceshipGame(),
|
||||
)
|
||||
..addGame(
|
||||
title: 'Spaceship Rail',
|
||||
description: SpaceshipRailGame.description,
|
||||
gameBuilder: (_) => SpaceshipRailGame(),
|
||||
)
|
||||
..addGame(
|
||||
title: 'Spaceship Ramp',
|
||||
description: SpaceshipRampGame.description,
|
||||
gameBuilder: (_) => SpaceshipRampGame(),
|
||||
);
|
||||
}
|
||||
|
@ -1,32 +1,25 @@
|
||||
import 'package:dashbook/dashbook.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:sandbox/common/common.dart';
|
||||
import 'package:sandbox/stories/backboard/backboard_game_over_game.dart';
|
||||
import 'package:sandbox/stories/backboard/backboard_waiting_game.dart';
|
||||
|
||||
void addBackboardStories(Dashbook dashbook) {
|
||||
dashbook.storiesOf('Backboard')
|
||||
..add(
|
||||
'Waiting mode',
|
||||
(context) => GameWidget(
|
||||
game: BackboardWaitingGame(),
|
||||
),
|
||||
codeLink: buildSourceLink('backboard/waiting.dart'),
|
||||
info: BackboardWaitingGame.info,
|
||||
..addGame(
|
||||
title: 'Waiting',
|
||||
description: BackboardWaitingGame.description,
|
||||
gameBuilder: (_) => BackboardWaitingGame(),
|
||||
)
|
||||
..add(
|
||||
'Game over',
|
||||
(context) => GameWidget(
|
||||
game: BackboardGameOverGame(
|
||||
context.numberProperty('Score', 9000000000).toInt(),
|
||||
context.listProperty(
|
||||
'Character',
|
||||
BackboardGameOverGame.characterIconPaths.keys.first,
|
||||
BackboardGameOverGame.characterIconPaths.keys.toList(),
|
||||
),
|
||||
..addGame(
|
||||
title: 'Game over',
|
||||
description: BackboardGameOverGame.description,
|
||||
gameBuilder: (context) => BackboardGameOverGame(
|
||||
context.numberProperty('Score', 9000000000).toInt(),
|
||||
context.listProperty(
|
||||
'Character',
|
||||
BackboardGameOverGame.characterIconPaths.keys.first,
|
||||
BackboardGameOverGame.characterIconPaths.keys.toList(),
|
||||
),
|
||||
),
|
||||
codeLink: buildSourceLink('backboard/game_over.dart'),
|
||||
info: BackboardGameOverGame.info,
|
||||
);
|
||||
}
|
||||
|
@ -1,15 +1,11 @@
|
||||
import 'package:dashbook/dashbook.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:sandbox/common/common.dart';
|
||||
import 'package:sandbox/stories/baseboard/baseboard_game.dart';
|
||||
|
||||
void addBaseboardStories(Dashbook dashbook) {
|
||||
dashbook.storiesOf('Baseboard').add(
|
||||
'Basic',
|
||||
(context) => GameWidget(
|
||||
game: BaseboardGame()..trace = context.boolProperty('Trace', true),
|
||||
),
|
||||
codeLink: buildSourceLink('baseboard_game/basic.dart'),
|
||||
info: BaseboardGame.info,
|
||||
dashbook.storiesOf('Baseboard').addGame(
|
||||
title: 'Traced',
|
||||
description: BaseboardGame.description,
|
||||
gameBuilder: (_) => BaseboardGame(),
|
||||
);
|
||||
}
|
||||
|
@ -1,15 +1,11 @@
|
||||
import 'package:dashbook/dashbook.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:sandbox/common/common.dart';
|
||||
import 'package:sandbox/stories/boundaries/boundaries_game.dart';
|
||||
|
||||
void addBoundariesStories(Dashbook dashbook) {
|
||||
dashbook.storiesOf('Boundaries').add(
|
||||
'Basic',
|
||||
(context) => GameWidget(
|
||||
game: BoundariesGame()..trace = context.boolProperty('Trace', true),
|
||||
),
|
||||
codeLink: buildSourceLink('boundaries_game/basic.dart'),
|
||||
info: BoundariesGame.info,
|
||||
dashbook.storiesOf('Boundaries').addGame(
|
||||
title: 'Traced',
|
||||
description: BoundariesGame.description,
|
||||
gameBuilder: (_) => BoundariesGame(),
|
||||
);
|
||||
}
|
||||
|
@ -1,15 +1,11 @@
|
||||
import 'package:dashbook/dashbook.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:sandbox/common/common.dart';
|
||||
import 'package:sandbox/stories/chrome_dino/chrome_dino_game.dart';
|
||||
|
||||
void addChromeDinoStories(Dashbook dashbook) {
|
||||
dashbook.storiesOf('Chrome Dino').add(
|
||||
'Basic',
|
||||
(context) => GameWidget(
|
||||
game: ChromeDinoGame(),
|
||||
),
|
||||
codeLink: buildSourceLink('chrome_dino/basic.dart'),
|
||||
info: ChromeDinoGame.info,
|
||||
dashbook.storiesOf('Chrome Dino').addGame(
|
||||
title: 'Trace',
|
||||
description: ChromeDinoGame.description,
|
||||
gameBuilder: (_) => ChromeDinoGame(),
|
||||
);
|
||||
}
|
||||
|
@ -1,13 +1,18 @@
|
||||
import 'package:dashbook/dashbook.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:sandbox/common/common.dart';
|
||||
import 'package:sandbox/stories/effects/camera_zoom_game.dart';
|
||||
import 'package:sandbox/stories/effects/fire_effect_game.dart';
|
||||
|
||||
void addEffectsStories(Dashbook dashbook) {
|
||||
dashbook.storiesOf('Effects').add(
|
||||
'Fire Effect',
|
||||
(context) => GameWidget(game: FireEffectGame()),
|
||||
codeLink: buildSourceLink('effects/fire_effect.dart'),
|
||||
info: FireEffectGame.info,
|
||||
);
|
||||
dashbook.storiesOf('Effects')
|
||||
..addGame(
|
||||
title: 'Fire',
|
||||
description: FireEffectGame.description,
|
||||
gameBuilder: (_) => FireEffectGame(),
|
||||
)
|
||||
..addGame(
|
||||
title: 'CameraZoom',
|
||||
description: CameraZoomGame.description,
|
||||
gameBuilder: (_) => CameraZoomGame(),
|
||||
);
|
||||
}
|
||||
|
@ -1,15 +1,11 @@
|
||||
import 'package:dashbook/dashbook.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:sandbox/common/common.dart';
|
||||
import 'package:sandbox/stories/flipper/flipper_game.dart';
|
||||
|
||||
void addFlipperStories(Dashbook dashbook) {
|
||||
dashbook.storiesOf('Flipper').add(
|
||||
'Basic',
|
||||
(context) => GameWidget(
|
||||
game: FlipperGame()..trace = context.boolProperty('Trace', true),
|
||||
),
|
||||
codeLink: buildSourceLink('flipper/basic.dart'),
|
||||
info: FlipperGame.info,
|
||||
dashbook.storiesOf('Flipper').addGame(
|
||||
title: 'Traced',
|
||||
description: FlipperGame.description,
|
||||
gameBuilder: (_) => FlipperGame(),
|
||||
);
|
||||
}
|
||||
|
@ -1,15 +1,11 @@
|
||||
import 'package:dashbook/dashbook.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:sandbox/common/common.dart';
|
||||
import 'package:sandbox/stories/google_word/google_letter_game.dart';
|
||||
|
||||
void addGoogleWordStories(Dashbook dashbook) {
|
||||
dashbook.storiesOf('Google Word').add(
|
||||
'Letter',
|
||||
(context) => GameWidget(
|
||||
game: GoogleLetterGame()..trace = context.boolProperty('Trace', true),
|
||||
),
|
||||
codeLink: buildSourceLink('google_word/letter.dart'),
|
||||
info: GoogleLetterGame.info,
|
||||
dashbook.storiesOf('Google Word').addGame(
|
||||
title: 'Letter 0',
|
||||
description: GoogleLetterGame.description,
|
||||
gameBuilder: (_) => GoogleLetterGame(),
|
||||
);
|
||||
}
|
||||
|
@ -1,15 +1,11 @@
|
||||
import 'package:dashbook/dashbook.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:sandbox/common/common.dart';
|
||||
import 'package:sandbox/stories/kicker/kicker_game.dart';
|
||||
|
||||
void addKickerStories(Dashbook dashbook) {
|
||||
dashbook.storiesOf('Kickers').add(
|
||||
'Basic',
|
||||
(context) => GameWidget(
|
||||
game: KickerGame()..trace = context.boolProperty('Trace', true),
|
||||
),
|
||||
codeLink: buildSourceLink('kicker_game/basic.dart'),
|
||||
info: KickerGame.info,
|
||||
dashbook.storiesOf('Kickers').addGame(
|
||||
title: 'Traced',
|
||||
description: KickerGame.description,
|
||||
gameBuilder: (_) => KickerGame(),
|
||||
);
|
||||
}
|
||||
|
@ -1,15 +1,11 @@
|
||||
import 'package:dashbook/dashbook.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:sandbox/common/common.dart';
|
||||
import 'package:sandbox/stories/launch_ramp/launch_ramp_game.dart';
|
||||
|
||||
void addLaunchRampStories(Dashbook dashbook) {
|
||||
dashbook.storiesOf('LaunchRamp').add(
|
||||
'Basic',
|
||||
(context) => GameWidget(
|
||||
game: LaunchRampGame()..trace = context.boolProperty('Trace', true),
|
||||
),
|
||||
codeLink: buildSourceLink('launch_ramp/basic.dart'),
|
||||
info: LaunchRampGame.info,
|
||||
dashbook.storiesOf('LaunchRamp').addGame(
|
||||
title: 'Traced',
|
||||
description: LaunchRampGame.description,
|
||||
gameBuilder: (_) => LaunchRampGame(),
|
||||
);
|
||||
}
|
||||
|
@ -1,18 +1,11 @@
|
||||
import 'package:dashbook/dashbook.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:sandbox/common/common.dart';
|
||||
import 'package:sandbox/stories/layer/basic_layer_game.dart';
|
||||
import 'package:sandbox/stories/layer/layer_game.dart';
|
||||
|
||||
void addLayerStories(Dashbook dashbook) {
|
||||
dashbook.storiesOf('Layer').add(
|
||||
'Layer',
|
||||
(context) => GameWidget(
|
||||
game: BasicLayerGame(
|
||||
color: context.colorProperty('color', Colors.blue),
|
||||
),
|
||||
),
|
||||
codeLink: buildSourceLink('layer/basic.dart'),
|
||||
info: BasicLayerGame.info,
|
||||
dashbook.storiesOf('Layer').addGame(
|
||||
title: 'Example',
|
||||
description: LayerGame.description,
|
||||
gameBuilder: (_) => LayerGame(),
|
||||
);
|
||||
}
|
||||
|
@ -1,15 +1,11 @@
|
||||
import 'package:dashbook/dashbook.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:sandbox/common/common.dart';
|
||||
import 'package:sandbox/stories/plunger/plunger_game.dart';
|
||||
|
||||
void addPlungerStories(Dashbook dashbook) {
|
||||
dashbook.storiesOf('Plunger').add(
|
||||
'Basic',
|
||||
(context) => GameWidget(
|
||||
game: PlungerGame()..trace = context.boolProperty('Trace', true),
|
||||
),
|
||||
codeLink: buildSourceLink('plunger_game/basic.dart'),
|
||||
info: PlungerGame.info,
|
||||
dashbook.storiesOf('Plunger').addGame(
|
||||
title: 'Traced',
|
||||
description: PlungerGame.description,
|
||||
gameBuilder: (_) => PlungerGame(),
|
||||
);
|
||||
}
|
||||
|
@ -1,15 +1,11 @@
|
||||
import 'package:dashbook/dashbook.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:sandbox/common/common.dart';
|
||||
import 'package:sandbox/stories/score_text/basic.dart';
|
||||
import 'package:sandbox/stories/score_text/score_text_game.dart';
|
||||
|
||||
void addScoreTextStories(Dashbook dashbook) {
|
||||
dashbook.storiesOf('ScoreText').add(
|
||||
'Basic',
|
||||
(context) => GameWidget(
|
||||
game: ScoreTextBasicGame(),
|
||||
),
|
||||
codeLink: buildSourceLink('score_text/basic.dart'),
|
||||
info: ScoreTextBasicGame.info,
|
||||
dashbook.storiesOf('ScoreText').addGame(
|
||||
title: 'Basic',
|
||||
description: ScoreTextGame.description,
|
||||
gameBuilder: (_) => ScoreTextGame(),
|
||||
);
|
||||
}
|
||||
|
@ -1,15 +1,11 @@
|
||||
import 'package:dashbook/dashbook.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:sandbox/common/common.dart';
|
||||
import 'package:sandbox/stories/slingshot/slingshot_game.dart';
|
||||
|
||||
void addSlingshotStories(Dashbook dashbook) {
|
||||
dashbook.storiesOf('Slingshots').add(
|
||||
'Basic',
|
||||
(context) => GameWidget(
|
||||
game: SlingshotGame()..trace = context.boolProperty('Trace', true),
|
||||
),
|
||||
codeLink: buildSourceLink('slingshot_game/basic.dart'),
|
||||
info: SlingshotGame.info,
|
||||
dashbook.storiesOf('Slingshots').addGame(
|
||||
title: 'Traced',
|
||||
description: SlingshotGame.description,
|
||||
gameBuilder: (_) => SlingshotGame(),
|
||||
);
|
||||
}
|
||||
|
@ -1,15 +0,0 @@
|
||||
import 'package:dashbook/dashbook.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:sandbox/common/common.dart';
|
||||
import 'package:sandbox/stories/spaceship/basic_spaceship_game.dart';
|
||||
|
||||
void addSpaceshipStories(Dashbook dashbook) {
|
||||
dashbook.storiesOf('Spaceship').add(
|
||||
'Basic',
|
||||
(context) => GameWidget(
|
||||
game: BasicSpaceshipGame(),
|
||||
),
|
||||
codeLink: buildSourceLink('spaceship/basic.dart'),
|
||||
info: BasicSpaceshipGame.info,
|
||||
);
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
import 'package:dashbook/dashbook.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:sandbox/common/common.dart';
|
||||
import 'package:sandbox/stories/spaceship_rail/spaceship_rail_game.dart';
|
||||
|
||||
void addSpaceshipRailStories(Dashbook dashbook) {
|
||||
dashbook.storiesOf('SpaceshipRail').add(
|
||||
'Basic',
|
||||
(context) => GameWidget(
|
||||
game: SpaceshipRailGame()
|
||||
..trace = context.boolProperty('Trace', true),
|
||||
),
|
||||
codeLink: buildSourceLink('spaceship_rail/basic.dart'),
|
||||
info: SpaceshipRailGame.info,
|
||||
);
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
import 'package:dashbook/dashbook.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:sandbox/common/common.dart';
|
||||
import 'package:sandbox/stories/spaceship_ramp/spaceship_ramp_game.dart';
|
||||
|
||||
void addSpaceshipRampStories(Dashbook dashbook) {
|
||||
dashbook.storiesOf('SpaceshipRamp').add(
|
||||
'Basic',
|
||||
(context) => GameWidget(
|
||||
game: SpaceshipRampGame()
|
||||
..trace = context.boolProperty('Trace', true),
|
||||
),
|
||||
codeLink: buildSourceLink('spaceship_ramp/basic.dart'),
|
||||
info: SpaceshipRampGame.info,
|
||||
);
|
||||
}
|
@ -1,15 +1,11 @@
|
||||
import 'package:dashbook/dashbook.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:sandbox/common/common.dart';
|
||||
import 'package:sandbox/stories/sparky_bumper/sparky_bumper_game.dart';
|
||||
|
||||
void addSparkyBumperStories(Dashbook dashbook) {
|
||||
dashbook.storiesOf('Sparky Bumpers').add(
|
||||
'Basic',
|
||||
(context) => GameWidget(
|
||||
game: SparkyBumperGame()..trace = context.boolProperty('Trace', true),
|
||||
),
|
||||
codeLink: buildSourceLink('sparky_bumper/basic.dart'),
|
||||
info: SparkyBumperGame.info,
|
||||
dashbook.storiesOf('Sparky Bumpers').addGame(
|
||||
title: 'Traced',
|
||||
description: SparkyBumperGame.description,
|
||||
gameBuilder: (_) => SparkyBumperGame(),
|
||||
);
|
||||
}
|
||||
|
@ -1,15 +0,0 @@
|
||||
import 'package:dashbook/dashbook.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:sandbox/common/common.dart';
|
||||
import 'package:sandbox/stories/zoom/basic_zoom_game.dart';
|
||||
|
||||
void addZoomStories(Dashbook dashbook) {
|
||||
dashbook.storiesOf('CameraZoom').add(
|
||||
'Basic',
|
||||
(context) => GameWidget(
|
||||
game: BasicCameraZoomGame(),
|
||||
),
|
||||
codeLink: buildSourceLink('zoom/basic_zoom_game.dart'),
|
||||
info: BasicCameraZoomGame.info,
|
||||
);
|
||||
}
|
Before Width: | Height: | Size: 1.0 MiB After Width: | Height: | Size: 1.0 MiB |
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 34 KiB |
@ -0,0 +1,76 @@
|
||||
// ignore_for_file: cascade_invocations
|
||||
|
||||
import 'package:flame/extensions.dart';
|
||||
import 'package:flame_test/flame_test.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pinball_components/pinball_components.dart';
|
||||
|
||||
import '../../helpers/helpers.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
group('SparkyAnimatronic', () {
|
||||
final asset = Assets.images.sparky.animatronic.keyName;
|
||||
final flameTester = FlameTester(() => TestGame([asset]));
|
||||
|
||||
flameTester.testGameWidget(
|
||||
'renders correctly',
|
||||
setUp: (game, tester) async {
|
||||
await game.images.load(asset);
|
||||
await game.ensureAdd(SparkyAnimatronic()..playing = true);
|
||||
await tester.pump();
|
||||
|
||||
game.camera.followVector2(Vector2.zero());
|
||||
},
|
||||
verify: (game, tester) async {
|
||||
final animationDuration =
|
||||
game.firstChild<SparkyAnimatronic>()!.animation!.totalDuration();
|
||||
|
||||
await expectLater(
|
||||
find.byGame<TestGame>(),
|
||||
matchesGoldenFile('golden/sparky_animatronic/start.png'),
|
||||
);
|
||||
|
||||
game.update(animationDuration * 0.25);
|
||||
await tester.pump();
|
||||
await expectLater(
|
||||
find.byGame<TestGame>(),
|
||||
matchesGoldenFile('golden/sparky_animatronic/middle.png'),
|
||||
);
|
||||
|
||||
game.update(animationDuration * 0.75);
|
||||
await tester.pump();
|
||||
await expectLater(
|
||||
find.byGame<TestGame>(),
|
||||
matchesGoldenFile('golden/sparky_animatronic/end.png'),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
flameTester.test(
|
||||
'loads correctly',
|
||||
(game) async {
|
||||
final sparkyAnimatronic = SparkyAnimatronic();
|
||||
await game.ensureAdd(sparkyAnimatronic);
|
||||
|
||||
expect(game.contains(sparkyAnimatronic), isTrue);
|
||||
},
|
||||
);
|
||||
|
||||
flameTester.test(
|
||||
'stops animating after animation completes',
|
||||
(game) async {
|
||||
final sparkyAnimatronic = SparkyAnimatronic();
|
||||
await game.ensureAdd(sparkyAnimatronic);
|
||||
|
||||
sparkyAnimatronic.playing = true;
|
||||
final animationDuration =
|
||||
game.firstChild<SparkyAnimatronic>()!.animation!.totalDuration();
|
||||
game.update(animationDuration);
|
||||
|
||||
expect(sparkyAnimatronic.playing, isFalse);
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
After Width: | Height: | Size: 127 KiB |
Before Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 226 KiB |
Before Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 150 KiB |
Before Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 206 KiB |
Before Width: | Height: | Size: 5.0 KiB |