diff --git a/lib/end_game/view/end_game_page.dart b/lib/end_game/view/end_game_page.dart index 6dbc81a..7b74304 100644 --- a/lib/end_game/view/end_game_page.dart +++ b/lib/end_game/view/end_game_page.dart @@ -35,8 +35,10 @@ class _EndGamePageState extends State { late StreamSubscription _gamepadSubscription; late GamepadNavigator _gamepadNavigator; - // TODO(any): display loading indicator on screen bool updatingFirebase = true; + bool minDurationElapsed = false; + + bool get canMoveOn => !updatingFirebase && minDurationElapsed; @override void initState() { @@ -44,13 +46,15 @@ class _EndGamePageState extends State { _updateFirebase(); _gamepadNavigator = GamepadNavigator( onAny: () { - if (updatingFirebase) { - return; + if (canMoveOn) { + Navigator.of(context).pushReplacement(TitlePage.route()); } - Navigator.of(context).pushReplacement(TitlePage.route()); }, ); _gamepadSubscription = Gamepads.events.listen(_gamepadNavigator.handle); + Future.delayed(const Duration(seconds: 10), () { + setState(() => minDurationElapsed = true); + }); } @override diff --git a/lib/game/components/ship.dart b/lib/game/components/ship.dart index a8e49d7..28bba03 100644 --- a/lib/game/components/ship.dart +++ b/lib/game/components/ship.dart @@ -93,7 +93,7 @@ class Ship extends SpriteComponent double engineStrength = 125.0; double bulletSpeed = 400.0; double weightFactor = 1.0; - double dragFactor = 5.0; + double dragFactor = 7.0; final double maxVelocity = 1500; final Vector2 velocity = Vector2.zero(); diff --git a/lib/game/components/spotlight.dart b/lib/game/components/spotlight.dart index 608db6c..3a3a0c1 100644 --- a/lib/game/components/spotlight.dart +++ b/lib/game/components/spotlight.dart @@ -21,6 +21,7 @@ class Spotlight extends CircleComponent final List currentShips = []; Ship? get activeShip => currentShips.length == 1 ? currentShips.first : null; + late final TimerComponent _scoreTimer; late final Rect _visibleArea; @@ -36,13 +37,19 @@ class Spotlight extends CircleComponent radius / 10, ); _scoreTimer = TimerComponent( - period: 1.0, + period: 0.5, repeat: true, autoStart: false, onTick: () => currentShips.firstOrNull?.score++, ); _visibleArea = game.playArea.deflate(_spotlightRadius); - addAll([CircleHitbox(isSolid: true), _scoreTimer]); + addAll([ + CircleHitbox( + isSolid: true, + collisionType: CollisionType.passive, + ), + _scoreTimer + ]); _updateRandomTarget(); _updateColor(); } diff --git a/lib/lobby/view/lobby_page.dart b/lib/lobby/view/lobby_page.dart index 8c2c264..b6434db 100644 --- a/lib/lobby/view/lobby_page.dart +++ b/lib/lobby/view/lobby_page.dart @@ -39,6 +39,7 @@ class _LobbyPageState extends State { _gamepadSubscription = Gamepads.events.listen((GamepadEvent event) { setState(() { if (startButton.matches(event) && + _players.isNotEmpty && !_players.any((p) => p.playerId == null)) { Navigator.of(context) .pushReplacement(GamePage.route(players: _players));