Merge branch 'main' into feat/character-selection

pull/20/head
Allison Ryan 4 years ago
commit 5a1093d9a5

2
.gitignore vendored

@ -125,3 +125,5 @@ app.*.map.json
!.idea/codeStyles/
!.idea/dictionaries/
!.idea/runConfigurations/
.firebase

@ -154,6 +154,33 @@ Update the `CFBundleLocalizations` array in the `Info.plist` at `ios/Runner/Info
}
```
### Deploy application to Firebase hosting
Follow the following steps to deploy the application.
## Firebase CLI
Install and authenticate with [Firebase CLI tools](https://firebase.google.com/docs/cli)
## Build the project using the desired environment
```bash
# Development
$ flutter build web --release --target lib/main_development.dart
# Staging
$ flutter build web --release --target lib/main_staging.dart
# Production
$ flutter build web --release --target lib/main_production.dart
```
## Deploy
```bash
$ firebase deploy
```
[coverage_badge]: coverage_badge.svg
[flutter_localizations_link]: https://api.flutter.dev/flutter/flutter_localizations/flutter_localizations-library.html
[internationalization_link]: https://flutter.dev/docs/development/accessibility-and-localization/internationalization

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

@ -0,0 +1,10 @@
{
"hosting": {
"public": "build/web",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}

@ -1,22 +1,34 @@
import 'package:flame_forge2d/body_component.dart';
import 'package:flame/components.dart';
import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:flutter/material.dart';
import 'package:forge2d/forge2d.dart';
import 'package:pinball/game/game.dart';
import 'package:pinball/theme/theme.dart';
class Ball extends BodyComponent<PinballGame> {
class Ball extends PositionBodyComponent<PinballGame, SpriteComponent> {
Ball({
required Vector2 position,
}) : _position = position;
}) : _position = position,
super(size: ballSize);
static final ballSize = Vector2.all(2);
final Vector2 _position;
static const spritePath = 'components/ball.png';
@override
Future<void> onLoad() async {
await super.onLoad();
final sprite = await gameRef.loadSprite(spritePath);
positionComponent = SpriteComponent(sprite: sprite, size: ballSize);
}
@override
Body createBody() {
paint = Paint()
..color = gameRef.read<ThemeCubit>().state.theme.characterTheme.ballColor;
final shape = CircleShape()..radius = 2;
final shape = CircleShape()..radius = ballSize.x / 2;
final fixtureDef = FixtureDef(shape)..density = 1;

@ -3,6 +3,9 @@
import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:pinball/game/components/components.dart';
/// {@template wall}
/// A continuos generic and [BodyType.static] barrier that divides a game area.
/// {@endtemplate}
class Wall extends BodyComponent {
Wall({
required this.start,
@ -29,6 +32,12 @@ class Wall extends BodyComponent {
}
}
/// {@template bottom_wall}
/// [Wall] located at the bottom of the board.
///
/// Collisions with [BottomWall] are listened by
/// [BottomWallBallContactCallback].
/// {@endtemplate}
class BottomWall extends Wall {
BottomWall(Forge2DGame game)
: super(
@ -40,6 +49,9 @@ class BottomWall extends Wall {
);
}
/// {@template bottom_wall_ball_contact_callback}
/// Listens when a [Ball] falls into a [BottomWall].
/// {@endtemplate}
class BottomWallBallContactCallback extends ContactCallback<Ball, BottomWall> {
@override
void begin(Ball ball, BottomWall wall, Contact contact) {

@ -1,4 +1,5 @@
export 'bloc/game_bloc.dart';
export 'components/components.dart';
export 'game_assets.dart';
export 'pinball_game.dart';
export 'view/view.dart';

@ -0,0 +1,11 @@
import 'package:pinball/game/game.dart';
/// Add methods to help loading and caching game assets.
extension PinballGameAssetsX on PinballGame {
/// Pre load the initial assets of the game.
Future<void> preLoadAssets() async {
await Future.wait([
images.load(Ball.spritePath),
]);
}
}

@ -1,10 +1,14 @@
import 'dart:async';
import 'package:flame_bloc/flame_bloc.dart';
import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:pinball/game/game.dart';
class PinballGame extends Forge2DGame with FlameBloc {
void spawnBall() {
add(Ball(position: ballStartingPosition));
add(
Ball(position: ballStartingPosition),
);
}
// TODO(erickzanardo): Change to the plumber position

@ -23,9 +23,26 @@ class PinballGamePage extends StatelessWidget {
}
}
class PinballGameView extends StatelessWidget {
class PinballGameView extends StatefulWidget {
const PinballGameView({Key? key}) : super(key: key);
@override
State<PinballGameView> createState() => _PinballGameViewState();
}
class _PinballGameViewState extends State<PinballGameView> {
late PinballGame _game;
@override
void initState() {
super.initState();
// TODO(erickzanardo): Revisit this when we start to have more assets
// this could expose a Stream (maybe even a cubit?) so we could show the
// the loading progress with some fancy widgets.
_game = PinballGame()..preLoadAssets();
}
@override
Widget build(BuildContext context) {
return BlocListener<GameBloc, GameState>(
@ -39,7 +56,7 @@ class PinballGameView extends StatelessWidget {
);
}
},
child: GameWidget<PinballGame>(game: PinballGame()),
child: GameWidget<PinballGame>(game: _game),
);
}
}

@ -140,21 +140,21 @@ packages:
name: flame
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-releasecandidate.1"
version: "1.1.0-releasecandidate.2"
flame_bloc:
dependency: "direct main"
description:
name: flame_bloc
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-releasecandidate.1"
version: "1.2.0-releasecandidate.2"
flame_forge2d:
dependency: "direct main"
description:
name: flame_forge2d
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.0-releasecandidate.1"
version: "0.9.0-releasecandidate.2"
flame_test:
dependency: "direct dev"
description:

@ -9,9 +9,9 @@ environment:
dependencies:
bloc: ^8.0.2
equatable: ^2.0.3
flame: ^1.1.0-releasecandidate.1
flame_bloc: ^1.2.0-releasecandidate.1
flame_forge2d: ^0.9.0-releasecandidate.1
flame: ^1.1.0-releasecandidate.2
flame_bloc: ^1.2.0-releasecandidate.2
flame_forge2d: ^0.9.0-releasecandidate.2
flutter:
sdk: flutter
flutter_bloc: ^8.0.1
@ -33,3 +33,6 @@ dev_dependencies:
flutter:
uses-material-design: true
generate: true
assets:
- assets/images/components/

@ -99,7 +99,7 @@ void main() {
final fixture = ball.body.fixtures[0];
expect(fixture.shape.shapeType, equals(ShapeType.circle));
expect(fixture.shape.radius, equals(2));
expect(fixture.shape.radius, equals(1));
},
);
});

Loading…
Cancel
Save