diff --git a/packages/trashy_road/lib/src/game/entities/bird/behaviors/bird_flying_behavior.dart b/packages/trashy_road/lib/src/game/entities/bird/behaviors/bird_flying_behavior.dart index 2d9da23d..eb0a4c33 100644 --- a/packages/trashy_road/lib/src/game/entities/bird/behaviors/bird_flying_behavior.dart +++ b/packages/trashy_road/lib/src/game/entities/bird/behaviors/bird_flying_behavior.dart @@ -5,13 +5,13 @@ import 'package:trashy_road/src/game/game.dart'; class BirdFlyingBehavior extends Behavior with HasGameReference { /// The speed multiplier for the bird. - static const birdSpeedMultiplier = 80; + static const birdSpeedMultiplier = 30; @override void update(double dt) { super.update(dt); - final distanceCovered = birdSpeedMultiplier * dt; + final distanceCovered = birdSpeedMultiplier * dt * parent.speed; final direction = parent.isFlyingRight ? 1 : -1; parent.position.x += distanceCovered * direction; diff --git a/packages/trashy_road/lib/src/game/entities/bird/bird.dart b/packages/trashy_road/lib/src/game/entities/bird/bird.dart index 0865b4d7..9f08cb7e 100644 --- a/packages/trashy_road/lib/src/game/entities/bird/bird.dart +++ b/packages/trashy_road/lib/src/game/entities/bird/bird.dart @@ -8,7 +8,7 @@ import 'package:trashy_road/src/game/game.dart'; export 'behaviors/behaviors.dart'; class Bird extends PositionedEntity with ZIndex { - Bird._({required this.isFlyingRight}) + Bird._({required this.isFlyingRight, required this.speed}) : super( scale: Vector2.all(0.5), behaviors: [ @@ -33,8 +33,9 @@ class Bird extends PositionedEntity with ZIndex { factory Bird.randomize() { final isFlyingRight = random.nextBool(); + final speed = minSpeed + random.nextDouble() * (maxSpeed - minSpeed); - return Bird._(isFlyingRight: isFlyingRight); + return Bird._(isFlyingRight: isFlyingRight, speed: speed); } static List randomAmount() { @@ -48,9 +49,15 @@ class Bird extends PositionedEntity with ZIndex { /// The maximum amount of birds that are loaded into a map. static const maxAmountOfBirds = 5; + static const maxSpeed = 3.0; + static const minSpeed = 1.0; + /// Whether the bird is flying right. final bool isFlyingRight; + /// Speed Multiplier + final double speed; + @override int get zIndex => 100000; }