From 2bbf7707016eb74993d26f53459bd7807f2d87e0 Mon Sep 17 00:00:00 2001 From: Luan Nico Date: Mon, 15 Jul 2024 22:07:25 -0400 Subject: [PATCH 1/2] First steps towards modernization --- game/.gitignore | 3 + game/.metadata | 24 +- game/analysis_options.yaml | 2 + .../images/{game_logo.png => game-logo.png} | Bin .../{spacebattle.png => space-battle.png} | Bin game/lib/game/ads.dart | 9 +- game/lib/game/analytics.dart | 8 +- game/lib/game/assets/char.dart | 5 +- game/lib/game/assets/poofs.dart | 3 +- game/lib/game/assets/spritesheet.dart | 7 +- game/lib/game/assets/tileset.dart | 7 +- game/lib/game/audio.dart | 35 +- game/lib/game/column.dart | 10 +- game/lib/game/components/background.dart | 27 +- game/lib/game/components/coin.dart | 6 +- game/lib/game/components/hud.dart | 10 +- game/lib/game/components/planet.dart | 12 +- game/lib/game/components/player.dart | 55 +- .../lib/game/components/player_particles.dart | 8 +- .../components/revamped/broken_glass.dart | 17 +- .../revamped/crystal_container_pickup.dart | 26 +- .../game/components/revamped/firing_ship.dart | 13 +- .../components/revamped/jetpack_pickup.dart | 38 +- game/lib/game/components/revamped/poof.dart | 5 +- .../game/components/revamped/powerups.dart | 25 +- .../components/revamped/space_battle.dart | 10 +- game/lib/game/components/stars.dart | 12 +- game/lib/game/components/tutorial.dart | 27 +- game/lib/game/components/wall.dart | 17 +- game/lib/game/game.dart | 117 +-- game/lib/game/game_data.dart | 5 +- game/lib/game/pause_overlay.dart | 7 +- game/lib/game/preferences.dart | 5 +- game/lib/game/rotation_manager.dart | 6 +- game/lib/game/rumble.dart | 3 +- game/lib/game/scoreboard.dart | 30 +- game/lib/game/spawner.dart | 2 +- game/lib/game/util.dart | 6 +- game/lib/main.dart | 60 +- game/lib/main_dashbook.dart | 13 +- game/lib/main_desktop.dart | 3 +- game/lib/screens/credits_screen.dart | 15 +- game/lib/screens/game_screen.dart | 41 +- game/lib/screens/join_scoreboard_screen.dart | 31 +- game/lib/screens/options_screen.dart | 19 +- game/lib/screens/scoreboard_screen.dart | 36 +- game/lib/screens/skins_screen.dart | 36 +- game/lib/widgets/button.dart | 12 +- game/lib/widgets/game_over.dart | 12 +- game/lib/widgets/gr_container.dart | 8 +- game/lib/widgets/label.dart | 13 +- game/lib/widgets/slide_in_container.dart | 9 +- game/lib/widgets/spritesheet_container.dart | 10 +- game/pubspec.lock | 820 +++++++++++------- game/pubspec.yaml | 37 +- 55 files changed, 1032 insertions(+), 745 deletions(-) rename game/assets/images/{game_logo.png => game-logo.png} (100%) rename game/assets/images/{spacebattle.png => space-battle.png} (100%) diff --git a/game/.gitignore b/game/.gitignore index 4e4d6c7..574f94e 100644 --- a/game/.gitignore +++ b/game/.gitignore @@ -14,6 +14,7 @@ *.ipr *.iws .idea/ +.vscode/ # The .vscode folder contains launch configuration and tasks you configure in # VS Code which you may wish to be included in version control, so this line @@ -35,3 +36,5 @@ lib/generated_plugin_registrant.dart # Exceptions to above rules. !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages .flutter-plugins-dependencies + +macos/ diff --git a/game/.metadata b/game/.metadata index 0958d28..22c0fa8 100644 --- a/game/.metadata +++ b/game/.metadata @@ -4,7 +4,27 @@ # This file should be version controlled and should not be manually edited. version: - revision: e70236e36ce1d32067dc68eb55519ec3e14b6b01 - channel: beta + revision: "2feea7a4071e25c1e3aac9c17016531bc4442f2a" + channel: "beta" project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 2feea7a4071e25c1e3aac9c17016531bc4442f2a + base_revision: 2feea7a4071e25c1e3aac9c17016531bc4442f2a + - platform: macos + create_revision: 2feea7a4071e25c1e3aac9c17016531bc4442f2a + base_revision: 2feea7a4071e25c1e3aac9c17016531bc4442f2a + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/game/analysis_options.yaml b/game/analysis_options.yaml index 0a73aed..9e4c9c1 100644 --- a/game/analysis_options.yaml +++ b/game/analysis_options.yaml @@ -3,6 +3,8 @@ include: package:flame_lint/analysis_options.yaml analyzer: exclude: - "**/*.g.dart" + errors: + avoid_print: ignore linter: rules: diff --git a/game/assets/images/game_logo.png b/game/assets/images/game-logo.png similarity index 100% rename from game/assets/images/game_logo.png rename to game/assets/images/game-logo.png diff --git a/game/assets/images/spacebattle.png b/game/assets/images/space-battle.png similarity index 100% rename from game/assets/images/spacebattle.png rename to game/assets/images/space-battle.png diff --git a/game/lib/game/ads.dart b/game/lib/game/ads.dart index 7b62a44..9ea5054 100644 --- a/game/lib/game/ads.dart +++ b/game/lib/game/ads.dart @@ -2,11 +2,10 @@ import 'dart:async'; import 'package:flutter/foundation.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart'; +import 'package:gravitational_waves/game/analytics.dart'; +import 'package:gravitational_waves/game/util.dart'; import 'package:oktoast/oktoast.dart'; -import 'analytics.dart'; -import 'util.dart'; - class Ads { static bool _loaded = false; static RewardedAd? _preloadedAd; @@ -79,11 +78,11 @@ class Ads { } ad.fullScreenContentCallback = null; ad.show( - onUserEarnedReward: (RewardedAd ad, RewardItem rewardItem) { + onUserEarnedReward: (_, __) { promise.complete(true); }, ); - } catch (ex) { + } on Exception catch (ex) { print('Unexpected error while loading ad: $ex'); showToast('Unexpected error while loading the ad.'); promise.complete(false); diff --git a/game/lib/game/analytics.dart b/game/lib/game/analytics.dart index 16b76da..8f152a2 100644 --- a/game/lib/game/analytics.dart +++ b/game/lib/game/analytics.dart @@ -14,9 +14,11 @@ String enumName(EventName enumVal) { class Analytics { static void log(EventName eventName) { try { - FirebaseAnalytics().logEvent(name: enumName(eventName).toLowerCase()); - } catch (ex) { - print('Unexpected error sending alalytics:'); + FirebaseAnalytics.instance.logEvent( + name: enumName(eventName).toLowerCase(), + ); + } on Exception catch (ex) { + print('Unexpected error sending analytics:'); print(ex); } } diff --git a/game/lib/game/assets/char.dart b/game/lib/game/assets/char.dart index b0adc09..aa63372 100644 --- a/game/lib/game/assets/char.dart +++ b/game/lib/game/assets/char.dart @@ -1,7 +1,6 @@ import 'package:flame/sprite.dart'; - -import '../skin.dart'; -import 'spritesheet.dart'; +import 'package:gravitational_waves/game/assets/spritesheet.dart'; +import 'package:gravitational_waves/game/skin.dart'; class Char { static late Spritesheet _sheet; diff --git a/game/lib/game/assets/poofs.dart b/game/lib/game/assets/poofs.dart index 10bcd44..59f9e84 100644 --- a/game/lib/game/assets/poofs.dart +++ b/game/lib/game/assets/poofs.dart @@ -1,6 +1,5 @@ import 'package:flame/components.dart'; - -import 'spritesheet.dart'; +import 'package:gravitational_waves/game/assets/spritesheet.dart'; class Poofs { static late Spritesheet _sheet; diff --git a/game/lib/game/assets/spritesheet.dart b/game/lib/game/assets/spritesheet.dart index 0553a9f..73158f2 100644 --- a/game/lib/game/assets/spritesheet.dart +++ b/game/lib/game/assets/spritesheet.dart @@ -9,7 +9,12 @@ const double _SRC_SIZE = 16.0; @JsonSerializable() class AnimationElement { - final int x, y, w, h, length, millis; + final int x; + final int y; + final int w; + final int h; + final int length; + final int millis; AnimationElement(this.x, this.y, this.w, this.h, this.length, this.millis); diff --git a/game/lib/game/assets/tileset.dart b/game/lib/game/assets/tileset.dart index c53f53a..b2f5c0b 100644 --- a/game/lib/game/assets/tileset.dart +++ b/game/lib/game/assets/tileset.dart @@ -1,10 +1,9 @@ import 'package:dartlin/dartlin.dart'; import 'package:flame/extensions.dart'; import 'package:flame/sprite.dart'; - -import '../collections.dart'; -import '../util.dart'; -import 'spritesheet.dart'; +import 'package:gravitational_waves/game/assets/spritesheet.dart'; +import 'package:gravitational_waves/game/collections.dart'; +import 'package:gravitational_waves/game/util.dart'; enum OuterTilePosition { topLeft, diff --git a/game/lib/game/audio.dart b/game/lib/game/audio.dart index 918a048..65c50be 100644 --- a/game/lib/game/audio.dart +++ b/game/lib/game/audio.dart @@ -1,18 +1,17 @@ -import 'package:audioplayers/audioplayers.dart'; import 'package:flame_audio/flame_audio.dart'; - -import 'preferences.dart'; -import 'util.dart'; +import 'package:gravitational_waves/game/preferences.dart'; +import 'package:gravitational_waves/game/util.dart'; class Audio { - static final AudioCache musicPlayer = _createLoopingPlayer( + static final AudioPlayer musicPlayer = _createLoopingPlayer( prefix: 'assets/audio/', ); - static AudioCache _createLoopingPlayer({required String prefix}) { + static AudioPlayer _createLoopingPlayer({required String prefix}) { final player = AudioPlayer(); - player.setReleaseMode(ReleaseMode.LOOP); - return AudioCache(prefix: prefix, fixedPlayer: player); + player.audioCache = AudioCache(prefix: prefix); + player.setReleaseMode(ReleaseMode.loop); + return player; } static Future init() async { @@ -40,33 +39,33 @@ class Audio { FlameAudio.play('sfx/$sound'); } - static void music(String song) async { + static Future music(String song) async { if (!ENABLE_AUDIO) { return; } if (!Preferences.instance.musicOn) { return; } - await musicPlayer.play('music/$song'); + await musicPlayer.play(AssetSource('music/$song')); } - static void stopMusic() async { - await musicPlayer.fixedPlayer?.stop(); + static Future stopMusic() async { + await musicPlayer.stop(); } - static void pauseMusic() async { - await musicPlayer.fixedPlayer?.pause(); + static Future pauseMusic() async { + await musicPlayer.pause(); } - static void resumeMusic() async { - await musicPlayer.fixedPlayer?.resume(); + static Future resumeMusic() async { + await musicPlayer.resume(); } - static void gameMusic() async { + static Future gameMusic() async { return music('dark-moon.mp3'); } - static void menuMusic() async { + static Future menuMusic() async { return music('contemplative-breaks.mp3'); } } diff --git a/game/lib/game/column.dart b/game/lib/game/column.dart index f68adec..059ca4b 100644 --- a/game/lib/game/column.dart +++ b/game/lib/game/column.dart @@ -1,11 +1,13 @@ -import 'assets/tileset.dart'; -import 'util.dart'; +import 'package:gravitational_waves/game/assets/tileset.dart'; +import 'package:gravitational_waves/game/util.dart'; class Column { static const OFFSET = 5; - int bottom, top; - late int bottomVariant, topVariant; + int bottom; + int top; + late int bottomVariant; + late int topVariant; Column(this.bottom, this.top) { bottomVariant = Tileset.randomVariant(); diff --git a/game/lib/game/components/background.dart b/game/lib/game/components/background.dart index ac5c6f0..842aadc 100644 --- a/game/lib/game/components/background.dart +++ b/game/lib/game/components/background.dart @@ -2,13 +2,12 @@ import 'dart:ui'; import 'package:dartlin/collections.dart'; import 'package:flame/components.dart'; - -import '../assets/tileset.dart'; -import '../column.dart'; -import '../game.dart'; -import '../palette.dart'; -import '../util.dart'; -import 'tutorial.dart'; +import 'package:gravitational_waves/game/assets/tileset.dart'; +import 'package:gravitational_waves/game/column.dart'; +import 'package:gravitational_waves/game/components/tutorial.dart'; +import 'package:gravitational_waves/game/game.dart'; +import 'package:gravitational_waves/game/palette.dart'; +import 'package:gravitational_waves/game/util.dart'; class Background extends PositionComponent with HasGameRef { static final Paint _bg = Palette.background.paint(); @@ -17,7 +16,7 @@ class Background extends PositionComponent with HasGameRef { Background(double x) { this.x = x; - columns = _generateChunck(CHUNK_SIZE).toList(); + columns = _generateChunk(CHUNK_SIZE).toList(); } Background.plains(double x) { @@ -34,9 +33,13 @@ class Background extends PositionComponent with HasGameRef { return List.generate(size, (_) => Column(0, 0)); } - static Iterable _generateChunck(int size) sync* { - int? beforeTop, beforeBottom; - var changesTop = 0, changesBottom = 0; + static Iterable _generateChunk(int size) sync* { + int? beforeTop; + int? beforeBottom; + + var changesTop = 0; + var changesBottom = 0; + for (var i = 0; i < size; i++) { if (i < 3 || i >= size - 3) { yield Column(0, 0); @@ -192,7 +195,7 @@ class Background extends PositionComponent with HasGameRef { @override void update(double dt) { super.update(dt); - if (endX < gameRef.camera.position.x - gameRef.size.x) { + if (endX < gameRef.cameraX - gameRef.size.x) { removeFromParent(); } } diff --git a/game/lib/game/components/coin.dart b/game/lib/game/components/coin.dart index d2a8e66..a4ba999 100644 --- a/game/lib/game/components/coin.dart +++ b/game/lib/game/components/coin.dart @@ -3,8 +3,8 @@ import 'dart:ui'; import 'package:flame/components.dart'; -import '../game.dart'; -import '../util.dart'; +import 'package:gravitational_waves/game/game.dart'; +import 'package:gravitational_waves/game/util.dart'; class Coin extends SpriteAnimationComponent with HasGameRef { static const double SRC_SIZE = 16.0; @@ -57,7 +57,7 @@ class Coin extends SpriteAnimationComponent with HasGameRef { return (x - this.x).abs() < 4 * SIZE; } - bool get offscreen => x < gameRef.camera.position.x - gameRef.size.x; + bool get offscreen => x < gameRef.cameraX - gameRef.size.x; @override int get priority => 4; diff --git a/game/lib/game/components/hud.dart b/game/lib/game/components/hud.dart index fb01f96..af2bc49 100644 --- a/game/lib/game/components/hud.dart +++ b/game/lib/game/components/hud.dart @@ -1,10 +1,9 @@ import 'dart:ui'; import 'package:flame/components.dart'; - -import '../game.dart'; -import '../util.dart'; -import 'coin.dart'; +import 'package:gravitational_waves/game/components/coin.dart'; +import 'package:gravitational_waves/game/game.dart'; +import 'package:gravitational_waves/game/util.dart'; class Hud extends Component with HasGameRef { static const double MARGIN = 8.0; @@ -54,9 +53,6 @@ class Hud extends Component with HasGameRef { Fonts.hud.render(c, p2, Vector2(x3, MARGIN)); } - @override - PositionType get positionType => PositionType.viewport; - @override int get priority => 6; } diff --git a/game/lib/game/components/planet.dart b/game/lib/game/components/planet.dart index d53133e..30eb842 100644 --- a/game/lib/game/components/planet.dart +++ b/game/lib/game/components/planet.dart @@ -1,9 +1,8 @@ import 'package:flame/components.dart'; - -import '../assets/tileset.dart'; -import '../collections.dart'; -import '../game.dart'; -import '../util.dart'; +import 'package:gravitational_waves/game/assets/tileset.dart'; +import 'package:gravitational_waves/game/collections.dart'; +import 'package:gravitational_waves/game/game.dart'; +import 'package:gravitational_waves/game/util.dart'; class Planet extends SpriteComponent with HasGameRef { Planet() { @@ -31,7 +30,4 @@ class Planet extends SpriteComponent with HasGameRef { @override int get priority => 1; - - @override - PositionType get positionType => PositionType.viewport; } diff --git a/game/lib/game/components/player.dart b/game/lib/game/components/player.dart index 0d52260..6a76b1e 100644 --- a/game/lib/game/components/player.dart +++ b/game/lib/game/components/player.dart @@ -1,17 +1,18 @@ import 'dart:ui'; import 'package:flame/components.dart'; +import 'package:flame/effects.dart'; import 'package:flame/extensions.dart'; - -import '../assets/char.dart'; -import '../game.dart'; -import '../game_data.dart'; -import '../palette.dart'; -import '../rumble.dart'; -import '../util.dart'; -import 'background.dart'; -import 'player_particles.dart'; -import 'revamped/jetpack_pickup.dart'; +import 'package:flame/sprite.dart'; +import 'package:gravitational_waves/game/assets/char.dart'; +import 'package:gravitational_waves/game/components/background.dart'; +import 'package:gravitational_waves/game/components/player_particles.dart'; +import 'package:gravitational_waves/game/components/revamped/jetpack_pickup.dart'; +import 'package:gravitational_waves/game/game.dart'; +import 'package:gravitational_waves/game/game_data.dart'; +import 'package:gravitational_waves/game/palette.dart'; +import 'package:gravitational_waves/game/rumble.dart'; +import 'package:gravitational_waves/game/util.dart'; class Player extends PositionComponent with HasGameRef { static const HURT_TIMER = 2.0; @@ -20,10 +21,12 @@ class Player extends PositionComponent with HasGameRef { double speedY; int livesLeft; - double hurtTimer = 0, shinyTimer = 0, invulnerabilityTimer = 0; + double hurtTimer = 0; + double shinyTimer = 0; + double invulnerabilityTimer = 0; JetpackType? jetpackType; - SpriteAnimation? jetpackAnimation; + SpriteAnimationTicker? jetpackAnimation; double jetpackTimeout = 0; bool hovering = false; @@ -141,7 +144,7 @@ class Player extends PositionComponent with HasGameRef { void renderParticles(Canvas c) { c.save(); c.translate(0, shouldFlip ? 0 : -BLOCK_SIZE); - particles.render(c, !jetpack); + particles.render(c, renderParticles: !jetpack); c.restore(); } @@ -252,7 +255,7 @@ class Player extends PositionComponent with HasGameRef { } Rect getCurrentRect() { - return gameRef.children + return gameRef.world.children .whereType() .firstWhere((c) => c.containsX(right)) .findRectContaining(right); @@ -270,7 +273,7 @@ class Player extends PositionComponent with HasGameRef { Vector2 goal, double speed, double dt, { - double treshold = 0.001, + double threshold = 0.001, }) { if (goal.x - width / 2 == x && goal.y - height / 2 == y) { return true; @@ -278,7 +281,7 @@ class Player extends PositionComponent with HasGameRef { final displacement = toCenter() - goal; final prevDist = displacement.length; - if (prevDist < treshold) { + if (prevDist < threshold) { x = goal.x - width / 2; y = goal.y - height / 2; return true; @@ -289,7 +292,7 @@ class Player extends PositionComponent with HasGameRef { y += delta.y; final newDist = (toCenter() - goal).length; - if (newDist < treshold || newDist > prevDist) { + if (newDist < threshold || newDist > prevDist) { // right there or overshoot, correct x = goal.x - width / 2; y = goal.y - height / 2; @@ -299,3 +302,21 @@ class Player extends PositionComponent with HasGameRef { return false; } } + +class PlayerCameraFollower extends ReadOnlyPositionProvider { + final MyGame game; + final Player player; + + final Vector2 _position = Vector2.zero(); + + PlayerCameraFollower({ + required this.game, + required this.player, + }); + + @override + Vector2 get position { + _position.x = player.position.x - game.size.x / 3; + return _position; + } +} diff --git a/game/lib/game/components/player_particles.dart b/game/lib/game/components/player_particles.dart index a94499a..596c8c0 100644 --- a/game/lib/game/components/player_particles.dart +++ b/game/lib/game/components/player_particles.dart @@ -1,9 +1,9 @@ import 'dart:ui'; + import 'package:flame/extensions.dart'; import 'package:flame/particles.dart'; - -import '../palette.dart'; -import '../util.dart'; +import 'package:gravitational_waves/game/palette.dart'; +import 'package:gravitational_waves/game/util.dart'; class PlayerParticles { final List jetpackParticles = []; @@ -25,7 +25,7 @@ class PlayerParticles { }); } - void render(Canvas c, bool renderParticles) { + void render(Canvas c, {required bool renderParticles}) { if (!particle.shouldRemove && renderParticles) { particle.render(c); } diff --git a/game/lib/game/components/revamped/broken_glass.dart b/game/lib/game/components/revamped/broken_glass.dart index 39f63d1..803ecad 100644 --- a/game/lib/game/components/revamped/broken_glass.dart +++ b/game/lib/game/components/revamped/broken_glass.dart @@ -1,15 +1,20 @@ import 'package:flame/components.dart'; import 'package:flame/extensions.dart'; +import 'package:flame/sprite.dart'; -import '../../assets/poofs.dart'; -import '../../game.dart'; -import '../../util.dart'; +import 'package:gravitational_waves/game/assets/poofs.dart'; +import 'package:gravitational_waves/game/game.dart'; +import 'package:gravitational_waves/game/util.dart'; class BrokenGlass extends PositionComponent with HasGameRef { static final Vector2 deltaCenter = Vector2.all(BLOCK_SIZE) / 2; - SpriteAnimation animation = Poofs.airEscaping(); - SpriteAnimation initialAnimation = Poofs.glassBreaking(); + SpriteAnimationTicker animation = SpriteAnimationTicker( + Poofs.airEscaping(), + ); + SpriteAnimationTicker initialAnimation = SpriteAnimationTicker( + Poofs.glassBreaking(), + ); BrokenGlass(double x, double y) { this.x = x; @@ -40,7 +45,7 @@ class BrokenGlass extends PositionComponent with HasGameRef { gameRef.player.suck(rect.center.toVector2()); } - if (x < gameRef.camera.position.x) { + if (x < gameRef.cameraX) { removeFromParent(); } } diff --git a/game/lib/game/components/revamped/crystal_container_pickup.dart b/game/lib/game/components/revamped/crystal_container_pickup.dart index 06bf91c..40c64d7 100644 --- a/game/lib/game/components/revamped/crystal_container_pickup.dart +++ b/game/lib/game/components/revamped/crystal_container_pickup.dart @@ -1,17 +1,17 @@ import 'dart:ui'; import 'package:flame/components.dart'; - -import '../../game.dart'; -import '../../util.dart'; -import '../coin.dart'; -import 'poof.dart'; +import 'package:flame/sprite.dart'; +import 'package:gravitational_waves/game/components/coin.dart'; +import 'package:gravitational_waves/game/components/revamped/poof.dart'; +import 'package:gravitational_waves/game/game.dart'; +import 'package:gravitational_waves/game/util.dart'; class CrystalContainerPickup extends SpriteComponent with HasGameRef { static const SPAWN_TIMER = 0.05; static const TOTAL_TIMER = 4; - late final SpriteAnimation animation; + late final SpriteAnimationTicker animation; // 0 idle, 1 spawning, 2 destroy int _state = 0; @@ -31,12 +31,14 @@ class CrystalContainerPickup extends SpriteComponent with HasGameRef { Future onLoad() async { await super.onLoad(); - animation = await SpriteAnimation.load( - 'crystal_container.png', - SpriteAnimationData.sequenced( - amount: 16, - textureSize: Vector2(16, 32), - stepTime: 0.150, + animation = SpriteAnimationTicker( + await SpriteAnimation.load( + 'crystal_container.png', + SpriteAnimationData.sequenced( + amount: 16, + textureSize: Vector2(16, 32), + stepTime: 0.150, + ), ), ); } diff --git a/game/lib/game/components/revamped/firing_ship.dart b/game/lib/game/components/revamped/firing_ship.dart index b355061..1c136ae 100644 --- a/game/lib/game/components/revamped/firing_ship.dart +++ b/game/lib/game/components/revamped/firing_ship.dart @@ -1,8 +1,7 @@ import 'package:flame/components.dart'; - -import '../../collections.dart'; -import '../../game.dart'; -import '../../util.dart'; +import 'package:gravitational_waves/game/collections.dart'; +import 'package:gravitational_waves/game/game.dart'; +import 'package:gravitational_waves/game/util.dart'; class FiringShip extends SpriteAnimationComponent with HasGameRef { static const scaleFactor = 2.0; @@ -13,7 +12,8 @@ class FiringShip extends SpriteAnimationComponent with HasGameRef { double myScale = 0; double clock = 0.0; - late List beforeHoleScales, afterHoleScales; + late List beforeHoleScales; + late List afterHoleScales; @override Future onLoad() async { @@ -71,7 +71,4 @@ class FiringShip extends SpriteAnimationComponent with HasGameRef { @override int get priority => 1; - - @override - PositionType get positionType => PositionType.viewport; } diff --git a/game/lib/game/components/revamped/jetpack_pickup.dart b/game/lib/game/components/revamped/jetpack_pickup.dart index 00a6de2..c0b749e 100644 --- a/game/lib/game/components/revamped/jetpack_pickup.dart +++ b/game/lib/game/components/revamped/jetpack_pickup.dart @@ -1,7 +1,7 @@ import 'package:flame/components.dart'; - -import '../../game.dart'; -import '../../util.dart'; +import 'package:flame/sprite.dart'; +import 'package:gravitational_waves/game/game.dart'; +import 'package:gravitational_waves/game/util.dart'; enum JetpackType { REGULAR, PULSER } @@ -12,7 +12,7 @@ class JetpackPickup extends SpriteComponent with HasGameRef { static const JETPACK_DURATION = 15.0; late final Sprite jetpack; - late final SpriteAnimation pulser; + late final SpriteAnimationTicker pulser; JetpackType type; double hoverClock = 0.0; @@ -30,29 +30,33 @@ class JetpackPickup extends SpriteComponent with HasGameRef { await super.onLoad(); jetpack = await Sprite.load('jetpack.png'); - pulser = await SpriteAnimation.load( - 'pulser.png', - SpriteAnimationData.sequenced( - amount: 6, - textureSize: Vector2.all(16), - loop: false, - stepTime: 0.15, + pulser = SpriteAnimationTicker( + await SpriteAnimation.load( + 'pulser.png', + SpriteAnimationData.sequenced( + amount: 6, + textureSize: Vector2.all(16), + loop: false, + stepTime: 0.15, + ), ), - ) - ..setToLast(); + )..setToLast(); } @override Sprite get sprite => getSpriteForType(); Sprite getSpriteForType() { - return type == JetpackType.REGULAR ? jetpack : pulser.frames[0].sprite; + return type == JetpackType.REGULAR + ? jetpack + : pulser.spriteAnimation.frames[0].sprite; } - SpriteAnimation getAnimationForType(JetpackType type) { - return type == JetpackType.REGULAR + SpriteAnimationTicker getAnimationForType(JetpackType type) { + final animation = type == JetpackType.REGULAR ? SpriteAnimation.spriteList([jetpack], stepTime: 0) - : pulser.clone(); + : pulser.spriteAnimation.clone(); + return SpriteAnimationTicker(animation); } @override diff --git a/game/lib/game/components/revamped/poof.dart b/game/lib/game/components/revamped/poof.dart index 9ffc3dd..cc10b0b 100644 --- a/game/lib/game/components/revamped/poof.dart +++ b/game/lib/game/components/revamped/poof.dart @@ -1,7 +1,6 @@ import 'package:flame/components.dart'; - -import '../../assets/poofs.dart'; -import '../../game.dart'; +import 'package:gravitational_waves/game/assets/poofs.dart'; +import 'package:gravitational_waves/game/game.dart'; class Poof extends SpriteAnimationComponent with HasGameRef { static const double SIZE = 16.0; diff --git a/game/lib/game/components/revamped/powerups.dart b/game/lib/game/components/revamped/powerups.dart index eb78f2d..d44f2ba 100644 --- a/game/lib/game/components/revamped/powerups.dart +++ b/game/lib/game/components/revamped/powerups.dart @@ -1,15 +1,14 @@ import 'package:dartlin/collections.dart'; import 'package:flame/components.dart'; - -import '../../collections.dart'; -import '../../game.dart'; -import '../../spawner.dart'; -import '../../util.dart'; -import '../background.dart'; -import 'crystal_container_pickup.dart'; -import 'firing_ship.dart'; -import 'jetpack_pickup.dart'; -import 'space_battle.dart'; +import 'package:gravitational_waves/game/collections.dart'; +import 'package:gravitational_waves/game/components/background.dart'; +import 'package:gravitational_waves/game/components/revamped/crystal_container_pickup.dart'; +import 'package:gravitational_waves/game/components/revamped/firing_ship.dart'; +import 'package:gravitational_waves/game/components/revamped/jetpack_pickup.dart'; +import 'package:gravitational_waves/game/components/revamped/space_battle.dart'; +import 'package:gravitational_waves/game/game.dart'; +import 'package:gravitational_waves/game/spawner.dart'; +import 'package:gravitational_waves/game/util.dart'; // change this if you want to easily test all powerups. const _M = 1.0; @@ -40,7 +39,7 @@ class Powerups extends Component with HasGameRef { if (!hasSpaceBattle) { spaceBattleSpawner.maybeSpawn(dt, () { hasSpaceBattle = true; - gameRef.add(SpaceBattle()); + gameRef.camera.viewport.add(SpaceBattle()); }); } @@ -61,7 +60,7 @@ class Powerups extends Component with HasGameRef { } Vector2? maybeGetOffscreenPosition() { - final offscreenX = gameRef.camera.position.x + gameRef.size.x + 1; + final offscreenX = gameRef.cameraX + gameRef.size.x + 1; final firstOffscreen = gameRef.children .whereType() .firstOrNull((c) => c.x > offscreenX); @@ -76,7 +75,7 @@ class Powerups extends Component with HasGameRef { void spawnFiringShip() { if (!gameRef.sleeping) { - gameRef.add(FiringShip()); + gameRef.camera.viewport.add(FiringShip()); } } } diff --git a/game/lib/game/components/revamped/space_battle.dart b/game/lib/game/components/revamped/space_battle.dart index fd94148..8f23058 100644 --- a/game/lib/game/components/revamped/space_battle.dart +++ b/game/lib/game/components/revamped/space_battle.dart @@ -1,7 +1,6 @@ import 'package:flame/components.dart'; - -import '../../game.dart'; -import '../../util.dart'; +import 'package:gravitational_waves/game/game.dart'; +import 'package:gravitational_waves/game/util.dart'; class SpaceBattle extends SpriteAnimationComponent with HasGameRef { static const S = 1.0; @@ -15,7 +14,7 @@ class SpaceBattle extends SpriteAnimationComponent with HasGameRef { await super.onLoad(); animation = await SpriteAnimation.load( - 'spacebattle.png', + 'space-battle.png', SpriteAnimationData.sequenced( amount: 12, textureSize: Vector2(TX_W, TX_H), @@ -44,7 +43,4 @@ class SpaceBattle extends SpriteAnimationComponent with HasGameRef { @override int get priority => 1; - - @override - PositionType get positionType => PositionType.viewport; } diff --git a/game/lib/game/components/stars.dart b/game/lib/game/components/stars.dart index db7c9e7..e5e06f5 100644 --- a/game/lib/game/components/stars.dart +++ b/game/lib/game/components/stars.dart @@ -1,11 +1,10 @@ import 'dart:ui'; import 'package:flame/components.dart'; - -import '../assets/tileset.dart'; -import '../collections.dart'; -import '../game.dart'; -import '../util.dart'; +import 'package:gravitational_waves/game/assets/tileset.dart'; +import 'package:gravitational_waves/game/collections.dart'; +import 'package:gravitational_waves/game/game.dart'; +import 'package:gravitational_waves/game/util.dart'; class Stars extends PositionComponent with HasGameRef { late List repeats; @@ -52,7 +51,4 @@ class Stars extends PositionComponent with HasGameRef { @override int get priority => 0; - - @override - PositionType get positionType => PositionType.viewport; } diff --git a/game/lib/game/components/tutorial.dart b/game/lib/game/components/tutorial.dart index de3ceaf..2106be6 100644 --- a/game/lib/game/components/tutorial.dart +++ b/game/lib/game/components/tutorial.dart @@ -1,10 +1,10 @@ import 'dart:ui'; import 'package:flame/components.dart'; - -import '../column.dart'; -import '../game.dart'; -import '../util.dart'; +import 'package:flame/sprite.dart'; +import 'package:gravitational_waves/game/column.dart'; +import 'package:gravitational_waves/game/game.dart'; +import 'package:gravitational_waves/game/util.dart'; class Tutorial extends Component with HasGameRef { static final positions = [64 - 6, 64 + 12] @@ -19,18 +19,20 @@ class Tutorial extends Component with HasGameRef { List.generate(8, (_) => Column(0, 0)); } - SpriteAnimation? animation; + SpriteAnimationTicker? animation; @override Future onLoad() async { await super.onLoad(); - animation = await SpriteAnimation.load( - 'hand.png', - SpriteAnimationData.sequenced( - amount: 2, - textureSize: Vector2(32.0, 48.0), - stepTime: 0.6, + animation = SpriteAnimationTicker( + await SpriteAnimation.load( + 'hand.png', + SpriteAnimationData.sequenced( + amount: 2, + textureSize: Vector2(32.0, 48.0), + stepTime: 0.6, + ), ), ); } @@ -59,7 +61,4 @@ class Tutorial extends Component with HasGameRef { @override int get priority => 7; - - @override - PositionType get positionType => PositionType.viewport; } diff --git a/game/lib/game/components/wall.dart b/game/lib/game/components/wall.dart index 30c25fd..9791921 100644 --- a/game/lib/game/components/wall.dart +++ b/game/lib/game/components/wall.dart @@ -3,13 +3,12 @@ import 'dart:ui'; import 'package:dartlin/dartlin.dart'; import 'package:flame/components.dart'; import 'package:flame/extensions.dart'; - -import '../assets/tileset.dart'; -import '../collections.dart'; -import '../game.dart'; -import '../palette.dart'; -import '../util.dart'; -import 'revamped/broken_glass.dart'; +import 'package:gravitational_waves/game/assets/tileset.dart'; +import 'package:gravitational_waves/game/collections.dart'; +import 'package:gravitational_waves/game/components/revamped/broken_glass.dart'; +import 'package:gravitational_waves/game/game.dart'; +import 'package:gravitational_waves/game/palette.dart'; +import 'package:gravitational_waves/game/util.dart'; class Wall extends PositionComponent with HasGameRef { static final Paint _wall = Palette.wall.paint(); @@ -37,7 +36,7 @@ class Wall extends PositionComponent with HasGameRef { } void renderColorBg(Canvas c) { - c.renderAt(gameRef.camera.position - position, (c) { + c.renderAt(gameRef.camera.viewfinder.position - position, (c) { final topBar = Rect.fromLTWH( -gameRef.size.x / 2, 0.0, @@ -58,7 +57,7 @@ class Wall extends PositionComponent with HasGameRef { void renderWall(Canvas c) { var dx = 0.0; var currentPane = currentStartingPane; - while (dx < gameRef.camera.position.x + gameRef.size.x + w - x) { + while (dx < gameRef.cameraX + gameRef.size.x + w - x) { final brokenType = brokenPanes[currentPane]; final sprite = diff --git a/game/lib/game/game.dart b/game/lib/game/game.dart index c62f535..5486f73 100644 --- a/game/lib/game/game.dart +++ b/game/lib/game/game.dart @@ -1,29 +1,30 @@ import 'dart:ui'; +import 'package:flame/components.dart'; +import 'package:flame/events.dart'; import 'package:flame/extensions.dart'; import 'package:flame/game.dart'; import 'package:flame/input.dart'; - -import 'analytics.dart'; -import 'audio.dart'; -import 'collections.dart'; -import 'components/background.dart'; -import 'components/coin.dart'; -import 'components/hud.dart'; -import 'components/planet.dart'; -import 'components/player.dart'; -import 'components/revamped/powerups.dart'; -import 'components/stars.dart'; -import 'components/tutorial.dart'; -import 'components/wall.dart'; -import 'game_data.dart'; -import 'palette.dart'; -import 'pause_overlay.dart'; -import 'rotation_manager.dart'; -import 'rumble.dart'; -import 'scoreboard.dart'; -import 'spawner.dart'; -import 'util.dart'; +import 'package:gravitational_waves/game/analytics.dart'; +import 'package:gravitational_waves/game/audio.dart'; +import 'package:gravitational_waves/game/collections.dart'; +import 'package:gravitational_waves/game/components/background.dart'; +import 'package:gravitational_waves/game/components/coin.dart'; +import 'package:gravitational_waves/game/components/hud.dart'; +import 'package:gravitational_waves/game/components/planet.dart'; +import 'package:gravitational_waves/game/components/player.dart'; +import 'package:gravitational_waves/game/components/revamped/powerups.dart'; +import 'package:gravitational_waves/game/components/stars.dart'; +import 'package:gravitational_waves/game/components/tutorial.dart'; +import 'package:gravitational_waves/game/components/wall.dart'; +import 'package:gravitational_waves/game/game_data.dart'; +import 'package:gravitational_waves/game/palette.dart'; +import 'package:gravitational_waves/game/pause_overlay.dart'; +import 'package:gravitational_waves/game/rotation_manager.dart'; +import 'package:gravitational_waves/game/rumble.dart'; +import 'package:gravitational_waves/game/scoreboard.dart'; +import 'package:gravitational_waves/game/spawner.dart'; +import 'package:gravitational_waves/game/util.dart'; class MyGame extends FlameGame with TapDetector { static Spawner planetSpawner = Spawner(0.12); @@ -32,6 +33,8 @@ class MyGame extends FlameGame with TapDetector { // to callback to the flutter code and go back to the menu void Function()? backToMenu; + // TODO(luan): reconsider this + // ignore: avoid_positional_boolean_parameters void Function(bool)? showGameOver; late RotationManager rotationManager; @@ -53,15 +56,20 @@ class MyGame extends FlameGame with TapDetector { late Wall wall; late Powerups powerups; + double get cameraX => camera.viewfinder.position.x; + @override Future onLoad() async { await super.onLoad(); - camera.viewport = FixedResolutionViewport( - Vector2(32, 18) * BLOCK_SIZE, - noClip: true, + final screenSize = Vector2(32, 18) * BLOCK_SIZE; + camera = CameraComponent.withFixedResolution( + width: screenSize.x, + height: screenSize.y, + // TODO(luan): figure this out + // noClip: true, ); - camera.speed = 50.0; + camera.moveBy(-screenSize / 2); await preStart(); } @@ -78,6 +86,8 @@ class MyGame extends FlameGame with TapDetector { coins = 0; hasUsedExtraLife = false; + // TODO(luan): figure out how to do this now + // ignore: invalid_use_of_internal_member children.clear(); if (isFirstTime) { showTutorial = 0; @@ -87,42 +97,47 @@ class MyGame extends FlameGame with TapDetector { await _addBg(Background.plains(lastGeneratedX)); } - add(powerups = Powerups()); - await add(player = Player()); - updateCamera(); + world.add(powerups = Powerups()); + await world.add(player = Player()); + setupCamera(); - await add(wall = Wall(firstX - size.x)); - await add(Stars()); + await world.add(wall = Wall(firstX - size.x)); + await camera.viewport.add(Stars()); rotationManager = RotationManager(); } - void updateCamera() { - camera.snapTo(Vector2(player.position.x - size.x / 3, 0)); + void setupCamera() { + camera.follow( + PlayerCameraFollower(game: this, player: player), + horizontalOnly: true, + ); } - void start(bool enablePowerups) { + void start({ + required bool enablePowerups, + }) { this.enablePowerups = enablePowerups; Analytics.log( enablePowerups ? EventName.START_REVAMPED : EventName.START_CLASSIC, ); sleeping = false; - add(hud = Hud()); + camera.viewport.add(hud = Hud()); powerups.reset(); - generateNextChunck(); + generateNextChunk(); Audio.gameMusic(); } Future restart() async { await preStart(); - start(enablePowerups); + start(enablePowerups: enablePowerups); } Background findBackgroundForX(double x) { return children.whereType().firstWhere((e) => e.containsX(x)); } - Future generateNextChunck() async { + Future generateNextChunk() async { while (lastGeneratedX < player.x + size.x) { final bg = Background(lastGeneratedX); await _addBg(bg); @@ -131,9 +146,9 @@ class MyGame extends FlameGame with TapDetector { x: lastGeneratedX, powerups: enablePowerups, ); - final amountCoints = R.nextInt(1 + coinLevel); + final amountCoins = R.nextInt(1 + coinLevel); final coins = []; - for (var i = 0; i < amountCoints; i++) { + for (var i = 0; i < amountCoins; i++) { final spot = bg.findRectFor(bg.columns.randomIdx(R)); final top = R.nextBool(); final x = spot.center.dx; @@ -144,25 +159,21 @@ class MyGame extends FlameGame with TapDetector { } final c = Coin(x, y); coins.add(c); - await add(c); + await world.add(c); } } } Future _addBg(Background bg) async { - await add(bg); + await world.add(bg); lastGeneratedX = bg.endX; - // we need to make sure the bg is actually added so - // it can be found by other components - children.updateComponentList(); } int get score => player.x ~/ 100; Future doShowTutorial() async { pause(); - await add(tutorial = Tutorial()); - children.updateComponentList(); + await camera.viewport.add(tutorial = Tutorial()); } @override @@ -173,7 +184,6 @@ class MyGame extends FlameGame with TapDetector { } super.update(t); - updateCamera(); if (showTutorial > -1 && player.x >= Tutorial.positions[showTutorial]) { doShowTutorial(); @@ -185,13 +195,13 @@ class MyGame extends FlameGame with TapDetector { if (!sleeping) { maybeGeneratePlanet(t); - generateNextChunck(); + generateNextChunk(); rotationManager.tick(t); } } void maybeGeneratePlanet(double dt) { - planetSpawner.maybeSpawn(dt, () => add(Planet())); + planetSpawner.maybeSpawn(dt, () => camera.viewport.add(Planet())); } void gainExtraLife() { @@ -214,7 +224,7 @@ class MyGame extends FlameGame with TapDetector { if (gamePaused) { final showMessage = tutorial == null; - PauseOverlay.render(canvas, canvasSize, showMessage); + PauseOverlay.render(canvas, canvasSize, showMessage: showMessage); } } @@ -265,6 +275,8 @@ class MyGame extends FlameGame with TapDetector { @override void lifecycleStateChange(AppLifecycleState state) { + super.lifecycleStateChange(state); + if (state != AppLifecycleState.resumed) { pause(); } else { @@ -272,7 +284,7 @@ class MyGame extends FlameGame with TapDetector { } } - void gameOver() async { + Future gameOver() async { Audio.die(); Audio.stopMusic(); @@ -290,6 +302,7 @@ class MyGame extends FlameGame with TapDetector { void vibrate() { Rumble.rumble(); - camera.shake(); + // TODO(luan): implement camera shake + // camera.shake(); } } diff --git a/game/lib/game/game_data.dart b/game/lib/game/game_data.dart index 8553583..c970247 100644 --- a/game/lib/game/game_data.dart +++ b/game/lib/game/game_data.dart @@ -1,11 +1,10 @@ import 'dart:async'; import 'dart:math' as math; +import 'package:gravitational_waves/game/skin.dart'; +import 'package:gravitational_waves/game/util.dart'; import 'package:json_annotation/json_annotation.dart'; -import 'skin.dart'; -import 'util.dart'; - part 'game_data.g.dart'; @JsonSerializable() diff --git a/game/lib/game/pause_overlay.dart b/game/lib/game/pause_overlay.dart index 31500ca..8131ffc 100644 --- a/game/lib/game/pause_overlay.dart +++ b/game/lib/game/pause_overlay.dart @@ -2,9 +2,8 @@ import 'dart:ui'; import 'package:flame/components.dart'; import 'package:flame/extensions.dart'; - -import 'palette.dart'; -import 'util.dart'; +import 'package:gravitational_waves/game/palette.dart'; +import 'package:gravitational_waves/game/util.dart'; class PauseOverlay { static final Paint _filled = Palette.hud.paint()..strokeWidth = 4.0; @@ -12,7 +11,7 @@ class PauseOverlay { ..strokeWidth = 6.0 ..style = PaintingStyle.stroke; - static void render(Canvas c, Vector2 size, bool showMessage) { + static void render(Canvas c, Vector2 size, {required bool showMessage}) { c.drawRect(Rect.fromLTWH(0.0, 0.0, size.x, size.y), _hollow); final xOffset = size.x - 8.0; diff --git a/game/lib/game/preferences.dart b/game/lib/game/preferences.dart index 9dc4ea7..ebb0616 100644 --- a/game/lib/game/preferences.dart +++ b/game/lib/game/preferences.dart @@ -1,10 +1,9 @@ import 'dart:async'; +import 'package:gravitational_waves/game/audio.dart'; +import 'package:gravitational_waves/game/util.dart'; import 'package:json_annotation/json_annotation.dart'; -import 'audio.dart'; -import 'util.dart'; - part 'preferences.g.dart'; @JsonSerializable() diff --git a/game/lib/game/rotation_manager.dart b/game/lib/game/rotation_manager.dart index 327124d..d2fbf66 100644 --- a/game/lib/game/rotation_manager.dart +++ b/game/lib/game/rotation_manager.dart @@ -1,6 +1,6 @@ -import 'collections.dart'; -import 'spawner.dart'; -import 'util.dart'; +import 'package:gravitational_waves/game/collections.dart'; +import 'package:gravitational_waves/game/spawner.dart'; +import 'package:gravitational_waves/game/util.dart'; class RotationManager { static final prob = [-1, 0, 0, 1]; diff --git a/game/lib/game/rumble.dart b/game/lib/game/rumble.dart index 17e591e..b08cc31 100644 --- a/game/lib/game/rumble.dart +++ b/game/lib/game/rumble.dart @@ -1,6 +1,5 @@ import 'package:flutter/services.dart' show HapticFeedback; - -import 'preferences.dart'; +import 'package:gravitational_waves/game/preferences.dart'; class Rumble { static void rumble() { diff --git a/game/lib/game/scoreboard.dart b/game/lib/game/scoreboard.dart index 4863b03..2805a3c 100644 --- a/game/lib/game/scoreboard.dart +++ b/game/lib/game/scoreboard.dart @@ -1,8 +1,7 @@ import 'package:dio/dio.dart'; import 'package:flame/flame.dart'; - -import 'game_data.dart'; -import 'skin.dart'; +import 'package:gravitational_waves/game/game_data.dart'; +import 'package:gravitational_waves/game/skin.dart'; // does not work rn const ENABLE_SCOREBOARD = false; @@ -22,13 +21,12 @@ class ScoreBoardEntry { required this.skin, }); - static ScoreBoardEntry fromJson(Map json) { - return ScoreBoardEntry( - skin: parseSkin(json['metadata'] as String), - score: (json['score'] as double).toInt(), - playerId: json['playerId'] as String, - ); - } + ScoreBoardEntry.fromJson(Map json) + : this( + skin: parseSkin(json['metadata'] as String), + score: (json['score'] as double).toInt(), + playerId: json['playerId'] as String, + ); } class ScoreBoard { @@ -44,8 +42,8 @@ class ScoreBoard { if (!ENABLE_SCOREBOARD) { return []; } - final _uuid = await getUuid(); - final resp = await Dio().get('$host/scores/$_uuid?sortOrder=DESC'); + final uuid = await getUuid(); + final resp = await Dio().get('$host/scores/$uuid?sortOrder=DESC'); final data = resp.data; if (data is List>) { @@ -60,9 +58,9 @@ class ScoreBoard { return false; } - final _uuid = await getUuid(); + final uuid = await getUuid(); final resp = await Dio() - .get('$host/scores/$_uuid?sortOrder=DESC&playerId=$playerId'); + .get('$host/scores/$uuid?sortOrder=DESC&playerId=$playerId'); final data = resp.data; @@ -90,8 +88,8 @@ class ScoreBoard { lastSubmittedScore == null || score > lastSubmittedScore) { // Get the token - final _uuid = await getUuid(); - final tokenResponse = await Dio().get('$host/scores/token/$_uuid'); + final uuid = await getUuid(); + final tokenResponse = await Dio().get('$host/scores/token/$uuid'); final token = tokenResponse.data?['token'] as String; final playerId = data.playerId; diff --git a/game/lib/game/spawner.dart b/game/lib/game/spawner.dart index 3eace2d..5f821ff 100644 --- a/game/lib/game/spawner.dart +++ b/game/lib/game/spawner.dart @@ -1,4 +1,4 @@ -import 'util.dart'; +import 'package:gravitational_waves/game/util.dart'; class Spawner { double chance; // chance per second diff --git a/game/lib/game/util.dart b/game/lib/game/util.dart index e435950..ddeb50a 100644 --- a/game/lib/game/util.dart +++ b/game/lib/game/util.dart @@ -4,17 +4,17 @@ import 'dart:math' as math; import 'package:dartlin/dartlin.dart'; import 'package:flame/game.dart'; import 'package:flutter/widgets.dart'; +import 'package:gravitational_waves/game/palette.dart'; import 'package:shared_preferences/shared_preferences.dart'; -import 'palette.dart'; - final R = math.Random(); const ENABLE_AUDIO = true; const DEBUG = false; const CHECK_PLAYER_ID = false; const ENABLE_REVAMP = true; -const ENABLE_ADS = true; +const ENABLE_ADS = false; +const ENABLE_FIREBASE = false; const BLOCK_SIZE = 16.0; const BLOCK_SIZE_INT = 16; diff --git a/game/lib/main.dart b/game/lib/main.dart index 19e955c..57cc07b 100644 --- a/game/lib/main.dart +++ b/game/lib/main.dart @@ -4,41 +4,43 @@ import 'package:flame_splash_screen/flame_splash_screen.dart'; import 'package:flutter/foundation.dart' show debugDefaultTargetPlatformOverride, kIsWeb; import 'package:flutter/material.dart'; +import 'package:gravitational_waves/game/ads.dart'; +import 'package:gravitational_waves/game/analytics.dart'; +import 'package:gravitational_waves/game/assets/char.dart'; +import 'package:gravitational_waves/game/assets/poofs.dart'; +import 'package:gravitational_waves/game/assets/tileset.dart'; +import 'package:gravitational_waves/game/audio.dart'; +import 'package:gravitational_waves/game/game_data.dart'; +import 'package:gravitational_waves/game/preferences.dart'; +import 'package:gravitational_waves/game/util.dart'; +import 'package:gravitational_waves/screens/credits_screen.dart'; +import 'package:gravitational_waves/screens/game_screen.dart'; +import 'package:gravitational_waves/screens/join_scoreboard_screen.dart'; +import 'package:gravitational_waves/screens/options_screen.dart'; +import 'package:gravitational_waves/screens/scoreboard_screen.dart'; +import 'package:gravitational_waves/screens/skins_screen.dart'; +import 'package:gravitational_waves/widgets/assets/ui_tileset.dart'; import 'package:oktoast/oktoast.dart'; -import './game/assets/char.dart'; -import './game/assets/tileset.dart'; -import './screens/credits_screen.dart'; -import './screens/game_screen.dart'; -import './screens/join_scoreboard_screen.dart'; -import './screens/options_screen.dart'; -import './screens/skins_screen.dart'; -import 'game/ads.dart'; -import 'game/analytics.dart'; -import 'game/assets/poofs.dart'; -import 'game/audio.dart'; -import 'game/game_data.dart'; -import 'game/preferences.dart'; -import 'screens/scoreboard_screen.dart'; -import 'widgets/assets/ui_tileset.dart'; - void main() async { print('Starting app...'); WidgetsFlutterBinding.ensureInitialized(); - await Firebase.initializeApp( - options: const FirebaseOptions( - apiKey: 'AIzaSyAwyHBokdzuZcW_iQ6hu_7DCrP6_DclSqg', - authDomain: 'fireslime-gravity-runner.firebaseapp.com', - databaseURL: 'https://fireslime-gravity-runner.firebaseio.com', - projectId: 'fireslime-gravity-runner', - storageBucket: 'fireslime-gravity-runner.appspot.com', - messagingSenderId: '107315711863', - appId: '1:107315711863:web:1c84176903b93eb824db72', - measurementId: 'G-E1SGKDJLF4', - ), - ); + if (ENABLE_FIREBASE) { + await Firebase.initializeApp( + options: const FirebaseOptions( + apiKey: 'AIzaSyAwyHBokdzuZcW_iQ6hu_7DCrP6_DclSqg', + authDomain: 'fireslime-gravity-runner.firebaseapp.com', + databaseURL: 'https://fireslime-gravity-runner.firebaseio.com', + projectId: 'fireslime-gravity-runner', + storageBucket: 'fireslime-gravity-runner.appspot.com', + messagingSenderId: '107315711863', + appId: '1:107315711863:web:1c84176903b93eb824db72', + measurementId: 'G-E1SGKDJLF4', + ), + ); + } await setMobileOrientation(); @@ -89,7 +91,7 @@ void main() async { '/credits': (BuildContext ctx) => const Scaffold( body: CreditsScreen(), ), - '/game': (BuildContext ctx) => Scaffold( + '/game': (BuildContext ctx) => const Scaffold( body: GameScreen(), ), }, diff --git a/game/lib/main_dashbook.dart b/game/lib/main_dashbook.dart index e3b1562..f9c29d2 100644 --- a/game/lib/main_dashbook.dart +++ b/game/lib/main_dashbook.dart @@ -1,11 +1,12 @@ +// NOTE: this is a development file to test widgets in isolation +// ignore: depend_on_referenced_packages import 'package:dashbook/dashbook.dart'; import 'package:flutter/material.dart'; - -import 'widgets/assets/ui_tileset.dart'; -import 'widgets/button.dart'; -import 'widgets/game_over.dart'; -import 'widgets/label.dart'; -import 'widgets/spritesheet_container.dart'; +import 'package:gravitational_waves/widgets/assets/ui_tileset.dart'; +import 'package:gravitational_waves/widgets/button.dart'; +import 'package:gravitational_waves/widgets/game_over.dart'; +import 'package:gravitational_waves/widgets/label.dart'; +import 'package:gravitational_waves/widgets/spritesheet_container.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); diff --git a/game/lib/main_desktop.dart b/game/lib/main_desktop.dart index d5c1dc4..3fceb2c 100644 --- a/game/lib/main_desktop.dart +++ b/game/lib/main_desktop.dart @@ -2,8 +2,7 @@ import 'package:flutter/foundation.dart' show debugDefaultTargetPlatformOverride; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; - -import './main.dart' as game; +import 'package:gravitational_waves/main.dart' as game; void main() async { debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; diff --git a/game/lib/screens/credits_screen.dart b/game/lib/screens/credits_screen.dart index f57588f..544e601 100644 --- a/game/lib/screens/credits_screen.dart +++ b/game/lib/screens/credits_screen.dart @@ -1,14 +1,13 @@ import 'package:flame/game.dart'; import 'package:flutter/material.dart'; - -import '../game/game.dart'; -import '../widgets/button.dart'; -import '../widgets/gr_container.dart'; -import '../widgets/label.dart'; -import '../widgets/palette.dart'; +import 'package:gravitational_waves/game/game.dart'; +import 'package:gravitational_waves/widgets/button.dart'; +import 'package:gravitational_waves/widgets/gr_container.dart'; +import 'package:gravitational_waves/widgets/label.dart'; +import 'package:gravitational_waves/widgets/palette.dart'; class CreditsScreen extends StatelessWidget { - const CreditsScreen({Key? key}) : super(key: key); + const CreditsScreen({super.key}); @override Widget build(BuildContext context) { @@ -43,7 +42,7 @@ class CreditsScreen extends StatelessWidget { const Link( link: 'https://fireslime.xyz', fontSize: 18, - ) + ), ], ), ), diff --git a/game/lib/screens/game_screen.dart b/game/lib/screens/game_screen.dart index 4101050..179ab60 100644 --- a/game/lib/screens/game_screen.dart +++ b/game/lib/screens/game_screen.dart @@ -3,25 +3,26 @@ import 'dart:io'; import 'package:flame/game.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; - -import '../game/ads.dart'; -import '../game/audio.dart'; -import '../game/game.dart'; -import '../game/game_data.dart'; -import '../game/util.dart'; -import '../widgets/button.dart'; -import '../widgets/game_over.dart'; -import '../widgets/label.dart'; -import '../widgets/slide_in_container.dart'; +import 'package:gravitational_waves/game/ads.dart'; +import 'package:gravitational_waves/game/audio.dart'; +import 'package:gravitational_waves/game/game.dart'; +import 'package:gravitational_waves/game/game_data.dart'; +import 'package:gravitational_waves/game/util.dart'; +import 'package:gravitational_waves/widgets/button.dart'; +import 'package:gravitational_waves/widgets/game_over.dart'; +import 'package:gravitational_waves/widgets/label.dart'; +import 'package:gravitational_waves/widgets/slide_in_container.dart'; class GameScreen extends StatefulWidget { + const GameScreen({super.key}); + @override State createState() { - return _GameScreenState(); + return GameScreenState(); } } -class _GameScreenState extends State { +class GameScreenState extends State { MyGame? game; bool _playing = false; bool _playSection = false; @@ -44,7 +45,7 @@ class _GameScreenState extends State { } void startGame({required bool enablePowerups}) { - game!.start(enablePowerups); + game!.start(enablePowerups: enablePowerups); setState(() { _playSection = false; @@ -52,9 +53,9 @@ class _GameScreenState extends State { }); } - void handleExtraLife() async { + Future handleExtraLife() async { if (game!.hasUsedExtraLife) { - print('You arealdy used your extra life.'); + print('You already used your extra life.'); return; } setState(() => _adLoading = true); @@ -83,7 +84,7 @@ class _GameScreenState extends State { from: const Offset(0.0, 1.5), duration: const Duration(milliseconds: 500), child: _adLoading - ? GameOverLoadingContainer() + ? const GameOverLoadingContainer() : GameOverContainer( distance: game.score, gems: game.coins, @@ -141,8 +142,10 @@ class _GameScreenState extends State { } else { sectionChildren.addAll([ Label( - label: - 'Total Gems: ${GameData.instance.coins} | High Score: ${GameData.instance.highScore ?? '-'}', + label: [ + 'Total Gems: ${GameData.instance.coins}', + 'High Score: ${GameData.instance.highScore ?? '-'}', + ].join(' | '), ), Row( mainAxisAlignment: MainAxisAlignment.center, @@ -198,7 +201,7 @@ class _GameScreenState extends State { curve: Curves.fastOutSlowIn, child: SlideInContainer( from: const Offset(0.0, -1.5), - child: Image.asset('assets/images/game_logo.png', width: 400), + child: Image.asset('assets/images/game-logo.png', width: 400), ), ), Expanded( diff --git a/game/lib/screens/join_scoreboard_screen.dart b/game/lib/screens/join_scoreboard_screen.dart index 758ec90..415a108 100644 --- a/game/lib/screens/join_scoreboard_screen.dart +++ b/game/lib/screens/join_scoreboard_screen.dart @@ -1,23 +1,22 @@ import 'package:flame/game.dart'; import 'package:flutter/material.dart'; - -import '../game/game.dart'; -import '../game/game_data.dart'; -import '../game/scoreboard.dart'; -import '../game/util.dart'; -import '../widgets/button.dart'; -import '../widgets/gr_container.dart'; -import '../widgets/label.dart'; -import '../widgets/palette.dart'; +import 'package:gravitational_waves/game/game.dart'; +import 'package:gravitational_waves/game/game_data.dart'; +import 'package:gravitational_waves/game/scoreboard.dart'; +import 'package:gravitational_waves/game/util.dart'; +import 'package:gravitational_waves/widgets/button.dart'; +import 'package:gravitational_waves/widgets/gr_container.dart'; +import 'package:gravitational_waves/widgets/label.dart'; +import 'package:gravitational_waves/widgets/palette.dart'; class JoinScoreboardScreen extends StatefulWidget { - const JoinScoreboardScreen({Key? key}) : super(key: key); + const JoinScoreboardScreen({super.key}); @override - _JoinScoreboardScreenState createState() => _JoinScoreboardScreenState(); + JoinScoreboardScreenState createState() => JoinScoreboardScreenState(); } -class _JoinScoreboardScreenState extends State { +class JoinScoreboardScreenState extends State { final playerIdTextController = TextEditingController(); String _status = ''; @@ -48,14 +47,14 @@ class _JoinScoreboardScreenState extends State { }); return isPlayerIdAvailable; - } catch (e) { + } on Exception catch (_) { setState(() => _status = 'Error'); } return false; } - void _join() async { + Future _join() async { final isPlayerIdAvailable = await _checkPlayerIdAvailability(); final highScore = GameData.instance.highScore; @@ -120,8 +119,8 @@ class _JoinScoreboardScreenState extends State { Label( label: '''By joining the scoreboard you agree that we collect your score, -your selected player skin and the choosen player id on the field above. -Those informations are only used for the display of the scoreboard. +your selected player skin and the chosen player id on the field above. +This information is only used for the display of the scoreboard. ''', fontColor: PaletteColors.blues.light, ), diff --git a/game/lib/screens/options_screen.dart b/game/lib/screens/options_screen.dart index 8c1ed15..437ffb7 100644 --- a/game/lib/screens/options_screen.dart +++ b/game/lib/screens/options_screen.dart @@ -1,21 +1,20 @@ import 'package:flame/game.dart'; import 'package:flutter/material.dart'; - -import '../game/game.dart'; -import '../game/preferences.dart'; -import '../widgets/button.dart'; -import '../widgets/gr_container.dart'; -import '../widgets/label.dart'; -import '../widgets/palette.dart'; +import 'package:gravitational_waves/game/game.dart'; +import 'package:gravitational_waves/game/preferences.dart'; +import 'package:gravitational_waves/widgets/button.dart'; +import 'package:gravitational_waves/widgets/gr_container.dart'; +import 'package:gravitational_waves/widgets/label.dart'; +import 'package:gravitational_waves/widgets/palette.dart'; class OptionsScreen extends StatefulWidget { - const OptionsScreen({Key? key}) : super(key: key); + const OptionsScreen({super.key}); @override - _OptionsScreenState createState() => _OptionsScreenState(); + OptionsScreenState createState() => OptionsScreenState(); } -class _OptionsScreenState extends State { +class OptionsScreenState extends State { @override Widget build(BuildContext context) { return Stack( diff --git a/game/lib/screens/scoreboard_screen.dart b/game/lib/screens/scoreboard_screen.dart index 3a28f2f..5cb7310 100644 --- a/game/lib/screens/scoreboard_screen.dart +++ b/game/lib/screens/scoreboard_screen.dart @@ -1,23 +1,22 @@ import 'package:flame/game.dart'; import 'package:flame/widgets.dart'; import 'package:flutter/material.dart'; - -import '../game/assets/char.dart'; -import '../game/game.dart'; -import '../game/game_data.dart'; -import '../game/scoreboard.dart'; -import '../widgets/button.dart'; -import '../widgets/label.dart'; -import '../widgets/palette.dart'; +import 'package:gravitational_waves/game/assets/char.dart'; +import 'package:gravitational_waves/game/game.dart'; +import 'package:gravitational_waves/game/game_data.dart'; +import 'package:gravitational_waves/game/scoreboard.dart'; +import 'package:gravitational_waves/widgets/button.dart'; +import 'package:gravitational_waves/widgets/label.dart'; +import 'package:gravitational_waves/widgets/palette.dart'; class ScoreboardScreen extends StatefulWidget { - const ScoreboardScreen({Key? key}) : super(key: key); + const ScoreboardScreen({super.key}); @override - _ScoreboardScreenState createState() => _ScoreboardScreenState(); + ScoreboardScreenState createState() => ScoreboardScreenState(); } -class _ScoreboardScreenState extends State { +class ScoreboardScreenState extends State { @override Widget build(BuildContext context) { return Stack( @@ -43,7 +42,7 @@ class _ScoreboardScreenState extends State { ), if (!ENABLE_SCOREBOARD) Label( - label: 'Scoreboard is disabeld for this build.', + label: 'Scoreboard is disabled for this build.', fontColor: PaletteColors.blues.light, fontSize: 24, ) @@ -74,7 +73,7 @@ class _ScoreboardScreenState extends State { final data = snapshot.data as List; return showScoreboard( context, - GameData.instance.playerId!, + GameData.instance.playerId, data[0] as List, ); } @@ -88,7 +87,7 @@ class _ScoreboardScreenState extends State { const SizedBox(height: 10), ], ), - ) + ), ], ), ); @@ -103,7 +102,7 @@ class _ScoreboardScreenState extends State { ? PaletteColors.pinks.dark : PaletteColors.blues.light; - final _list = ListView( + final list = ListView( padding: const EdgeInsets.all(10), children: (entries ?? []).asMap().entries.map((entry) { return Container( @@ -122,7 +121,8 @@ class _ScoreboardScreenState extends State { const SizedBox(width: 5), SpriteWidget( sprite: Char.fromSkin(entry.value.skin), - srcSize: Vector2(60.0, 40.0), + // TODO(luan): figure out sprite widget size + // srcSize: Vector2(60.0, 40.0), ), Label( fontColor: fontColor(entry.value), @@ -169,12 +169,12 @@ class _ScoreboardScreenState extends State { onPress: () => Navigator.pushReplacementNamed(context, '/join-scoreboard'), ), - Expanded(child: _list), + Expanded(child: list), ], ), ); } else { - return Flexible(child: _list); + return Flexible(child: list); } } } diff --git a/game/lib/screens/skins_screen.dart b/game/lib/screens/skins_screen.dart index 7308153..958e902 100644 --- a/game/lib/screens/skins_screen.dart +++ b/game/lib/screens/skins_screen.dart @@ -3,24 +3,23 @@ import 'dart:ui'; import 'package:flame/game.dart'; import 'package:flame/widgets.dart'; import 'package:flutter/material.dart'; - -import '../game/assets/char.dart'; -import '../game/game.dart'; -import '../game/game_data.dart'; -import '../game/skin.dart'; -import '../widgets/button.dart'; -import '../widgets/gr_container.dart'; -import '../widgets/label.dart'; -import '../widgets/palette.dart'; +import 'package:gravitational_waves/game/assets/char.dart'; +import 'package:gravitational_waves/game/game.dart'; +import 'package:gravitational_waves/game/game_data.dart'; +import 'package:gravitational_waves/game/skin.dart'; +import 'package:gravitational_waves/widgets/button.dart'; +import 'package:gravitational_waves/widgets/gr_container.dart'; +import 'package:gravitational_waves/widgets/label.dart'; +import 'package:gravitational_waves/widgets/palette.dart'; class SkinsScreen extends StatefulWidget { - const SkinsScreen({Key? key}) : super(key: key); + const SkinsScreen({super.key}); @override - _SkinsScreenState createState() => _SkinsScreenState(); + SkinsScreenState createState() => SkinsScreenState(); } -class _SkinsScreenState extends State { +class SkinsScreenState extends State { Skin? _skinToBuy; @override @@ -64,12 +63,13 @@ class _SkinsScreenState extends State { final price = skinPrice(v); final sprite = Char.fromSkin(v); final flameWidget = SizedBox( + width: 100.0, + height: 100.0, child: SpriteWidget( sprite: sprite, - srcSize: Vector2(100.0, 80.0), + // TODO(luan): figure out sprite widget size + // size: Vector2(100.0, 80.0), ), - width: 100.0, - height: 100.0, ); final widget = isOwned ? flameWidget @@ -80,12 +80,12 @@ class _SkinsScreenState extends State { child: flameWidget, ), Positioned( + right: 2.0, + top: 2.0, child: Label( label: '$price gems', fontColor: PaletteColors.blues.light, ), - right: 2.0, - top: 2.0, ), ], ); @@ -144,7 +144,7 @@ class _SkinsScreenState extends State { onPress: () => setState(() { _skinToBuy = null; }), - ) + ), ], ), ); diff --git a/game/lib/widgets/button.dart b/game/lib/widgets/button.dart index 18fef0f..e4dbd43 100644 --- a/game/lib/widgets/button.dart +++ b/game/lib/widgets/button.dart @@ -1,24 +1,19 @@ import 'package:flutter/material.dart'; - -import 'palette.dart'; +import 'package:gravitational_waves/widgets/palette.dart'; typedef OnPress = void Function(); class PrimaryButton extends Button { - PrimaryButton({required String label, OnPress? onPress}) + PrimaryButton({required super.label, super.key, super.onPress}) : super( - label: label, - onPress: onPress, fontColor: PaletteColors.pinks.normal, backgroundColor: PaletteColors.blues.light, ); } class SecondaryButton extends Button { - SecondaryButton({required String label, OnPress? onPress}) + SecondaryButton({required super.label, super.key, super.onPress}) : super( - label: label, - onPress: onPress, fontColor: PaletteColors.blues.light, backgroundColor: PaletteColors.pinks.normal, ); @@ -34,6 +29,7 @@ class Button extends StatelessWidget { const Button({ required this.label, + super.key, this.onPress, this.fontColor, this.backgroundColor, diff --git a/game/lib/widgets/game_over.dart b/game/lib/widgets/game_over.dart index f6d524a..ff4609d 100644 --- a/game/lib/widgets/game_over.dart +++ b/game/lib/widgets/game_over.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; - -import 'button.dart'; -import 'gr_container.dart'; -import 'label.dart'; -import 'palette.dart'; +import 'package:gravitational_waves/widgets/button.dart'; +import 'package:gravitational_waves/widgets/gr_container.dart'; +import 'package:gravitational_waves/widgets/label.dart'; +import 'package:gravitational_waves/widgets/palette.dart'; class _Line extends StatelessWidget { final String leftLabel; @@ -54,6 +53,7 @@ class GameOverContainer extends StatelessWidget { required this.goToMainMenu, required this.playAgain, required this.extraLife, + super.key, }); @override @@ -87,6 +87,8 @@ class GameOverContainer extends StatelessWidget { } class GameOverLoadingContainer extends StatelessWidget { + const GameOverLoadingContainer({super.key}); + @override Widget build(BuildContext context) { return const GRContainer( diff --git a/game/lib/widgets/gr_container.dart b/game/lib/widgets/gr_container.dart index d070140..2861c55 100644 --- a/game/lib/widgets/gr_container.dart +++ b/game/lib/widgets/gr_container.dart @@ -1,7 +1,6 @@ import 'package:flutter/widgets.dart'; - -import 'assets/ui_tileset.dart'; -import 'spritesheet_container.dart'; +import 'package:gravitational_waves/widgets/assets/ui_tileset.dart'; +import 'package:gravitational_waves/widgets/spritesheet_container.dart'; class GRContainer extends StatelessWidget { final double? width; @@ -13,6 +12,7 @@ class GRContainer extends StatelessWidget { const GRContainer({ required this.child, + super.key, this.width, this.height, this.padding, @@ -24,10 +24,10 @@ class GRContainer extends StatelessWidget { padding: padding, width: width, height: height, - child: child, spriteSheet: UITileset.tileset, tileSize: 16, destTileSize: 30, + child: child, ); } } diff --git a/game/lib/widgets/label.dart b/game/lib/widgets/label.dart index a14b60a..b109a15 100644 --- a/game/lib/widgets/label.dart +++ b/game/lib/widgets/label.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; +import 'package:gravitational_waves/widgets/palette.dart'; import 'package:url_launcher/url_launcher.dart'; -import 'palette.dart'; - class Label extends Text { Label({ required String label, + super.key, Color fontColor = Colors.white, double fontSize = 12.0, TextAlign? textAlign, @@ -24,7 +24,7 @@ class Link extends StatelessWidget { final String link; final double fontSize; - const Link({required this.link, required this.fontSize}); + const Link({required this.link, required this.fontSize, super.key}); @override Widget build(BuildContext context) => GestureDetector( @@ -36,9 +36,10 @@ class Link extends StatelessWidget { ), ); - void _onTap() async { - if (await canLaunch(link)) { - await launch(link); + Future _onTap() async { + final url = Uri.http(link); + if (await canLaunchUrl(url)) { + await launchUrl(url); } else { throw 'Could not launch $link'; } diff --git a/game/lib/widgets/slide_in_container.dart b/game/lib/widgets/slide_in_container.dart index 311427e..665399c 100644 --- a/game/lib/widgets/slide_in_container.dart +++ b/game/lib/widgets/slide_in_container.dart @@ -9,17 +9,18 @@ class SlideInContainer extends StatefulWidget { const SlideInContainer({ required this.child, - this.from = const Offset(0.0, 0.0), - this.to = const Offset(0.0, 0.0), + super.key, + this.from = Offset.zero, + this.to = Offset.zero, this.duration = const Duration(seconds: 1), this.curve = Curves.easeInExpo, }); @override - _SlideInContainer createState() => _SlideInContainer(); + SlideInContainerState createState() => SlideInContainerState(); } -class _SlideInContainer extends State +class SlideInContainerState extends State with SingleTickerProviderStateMixin { late AnimationController _controller; late Animation _offsetAnimation; diff --git a/game/lib/widgets/spritesheet_container.dart b/game/lib/widgets/spritesheet_container.dart index 3bad6f0..2081111 100644 --- a/game/lib/widgets/spritesheet_container.dart +++ b/game/lib/widgets/spritesheet_container.dart @@ -75,12 +75,7 @@ class _Painter extends widgets.CustomPainter { x = x + destTileSize) { middle.renderRect( canvas, - Rect.fromLTWH( - x, - y, - destTileSize, - destTileSize, - ), + Rect.fromLTWH(x, y, destTileSize, destTileSize), ); } } @@ -192,6 +187,7 @@ class SpritesheetContainer extends widgets.StatelessWidget { required this.spriteSheet, required this.tileSize, required this.destTileSize, + super.key, this.width, this.height, this.padding, @@ -209,8 +205,8 @@ class SpritesheetContainer extends widgets.StatelessWidget { destTileSize: destTileSize, ), child: widgets.Container( - child: child, padding: padding, + child: child, ), ), ); diff --git a/game/pubspec.lock b/game/pubspec.lock index f1c6dd8..c8dc0b7 100644 --- a/game/pubspec.lock +++ b/game/pubspec.lock @@ -5,310 +5,407 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - url: "https://pub.dartlang.org" + sha256: "5aaf60d96c4cd00fe7f21594b5ad6a1b699c80a27420f8a837f4d68473ef09e3" + url: "https://pub.dev" source: hosted - version: "30.0.0" + version: "68.0.0" + _flutterfire_internals: + dependency: transitive + description: + name: _flutterfire_internals + sha256: b46f62516902afb04befa4b30eb6a12ac1f58ca8cb25fb9d632407259555dd3d + url: "https://pub.dev" + source: hosted + version: "1.3.39" + _macros: + dependency: transitive + description: dart + source: sdk + version: "0.1.5" analyzer: dependency: transitive description: name: analyzer - url: "https://pub.dartlang.org" + sha256: "21f1d3720fd1c70316399d5e2bccaebb415c434592d778cce8acb967b8578808" + url: "https://pub.dev" source: hosted - version: "2.7.0" + version: "6.5.0" archive: dependency: transitive description: name: archive - url: "https://pub.dartlang.org" + sha256: cb6a278ef2dbb298455e1a713bda08524a175630ec643a242c399c932a0a1f7d + url: "https://pub.dev" source: hosted - version: "3.1.6" + version: "3.6.1" args: dependency: transitive description: name: args - url: "https://pub.dartlang.org" + sha256: "7cf60b9f0cc88203c5a190b4cd62a99feea42759a7fa695010eb5de1c0b2252a" + url: "https://pub.dev" source: hosted - version: "2.3.0" + version: "2.5.0" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.9.0" + version: "2.11.0" audioplayers: dependency: transitive description: name: audioplayers - url: "https://pub.dartlang.org" + sha256: "752039d6aa752597c98ec212e9759519061759e402e7da59a511f39d43aa07d2" + url: "https://pub.dev" + source: hosted + version: "6.0.0" + audioplayers_android: + dependency: transitive + description: + name: audioplayers_android + sha256: de576b890befe27175c2f511ba8b742bec83765fa97c3ce4282bba46212f58e4 + url: "https://pub.dev" + source: hosted + version: "5.0.0" + audioplayers_darwin: + dependency: transitive + description: + name: audioplayers_darwin + sha256: e507887f3ff18d8e5a10a668d7bedc28206b12e10b98347797257c6ae1019c3b + url: "https://pub.dev" + source: hosted + version: "6.0.0" + audioplayers_linux: + dependency: transitive + description: + name: audioplayers_linux + sha256: "3d3d244c90436115417f170426ce768856d8fe4dfc5ed66a049d2890acfa82f9" + url: "https://pub.dev" + source: hosted + version: "4.0.0" + audioplayers_platform_interface: + dependency: transitive + description: + name: audioplayers_platform_interface + sha256: "6834dd48dfb7bc6c2404998ebdd161f79cd3774a7e6779e1348d54a3bfdcfaa5" + url: "https://pub.dev" + source: hosted + version: "7.0.0" + audioplayers_web: + dependency: transitive + description: + name: audioplayers_web + sha256: db8fc420dadf80da18e2286c18e746fb4c3b2c5adbf0c963299dde046828886d + url: "https://pub.dev" + source: hosted + version: "5.0.0" + audioplayers_windows: + dependency: transitive + description: + name: audioplayers_windows + sha256: "8605762dddba992138d476f6a0c3afd9df30ac5b96039929063eceed416795c2" + url: "https://pub.dev" source: hosted - version: "0.20.1" + version: "4.0.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" build: dependency: transitive description: name: build - url: "https://pub.dartlang.org" + sha256: "80184af8b6cb3e5c1c4ec6d8544d27711700bc3e6d2efad04238c7b5290889f0" + url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.4.1" build_config: dependency: transitive description: name: build_config - url: "https://pub.dartlang.org" + sha256: bf80fcfb46a29945b423bd9aad884590fb1dc69b330a4d4700cac476af1708d1 + url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "1.1.1" build_daemon: dependency: transitive description: name: build_daemon - url: "https://pub.dartlang.org" + sha256: "79b2aef6ac2ed00046867ed354c88778c9c0f029df8a20fe10b5436826721ef9" + url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "4.0.2" build_resolvers: dependency: transitive description: name: build_resolvers - url: "https://pub.dartlang.org" + sha256: "339086358431fa15d7eca8b6a36e5d783728cf025e559b834f4609a1fcfb7b0a" + url: "https://pub.dev" source: hosted - version: "2.0.5" + version: "2.4.2" build_runner: dependency: "direct dev" description: name: build_runner - url: "https://pub.dartlang.org" + sha256: "644dc98a0f179b872f612d3eb627924b578897c629788e858157fa5e704ca0c7" + url: "https://pub.dev" source: hosted - version: "2.1.5" + version: "2.4.11" build_runner_core: dependency: transitive description: name: build_runner_core - url: "https://pub.dartlang.org" + sha256: e3c79f69a64bdfcd8a776a3c28db4eb6e3fb5356d013ae5eb2e52007706d5dbe + url: "https://pub.dev" source: hosted - version: "7.2.2" + version: "7.3.1" built_collection: dependency: transitive description: name: built_collection - url: "https://pub.dartlang.org" + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" source: hosted version: "5.1.1" built_value: dependency: transitive description: name: built_value - url: "https://pub.dartlang.org" + sha256: c7913a9737ee4007efedaffc968c049fd0f3d0e49109e778edc10de9426005cb + url: "https://pub.dev" source: hosted - version: "8.1.3" + version: "8.9.2" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.1" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.3.1" + version: "1.3.0" checked_yaml: dependency: transitive description: name: checked_yaml - url: "https://pub.dartlang.org" + sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff + url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.0.3" cli_util: dependency: transitive description: name: cli_util - url: "https://pub.dartlang.org" + sha256: c05b7406fdabc7a49a3929d4af76bcaccbbffcbcdcf185b082e1ae07da323d19 + url: "https://pub.dev" source: hosted - version: "0.3.5" + version: "0.4.1" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted version: "1.1.1" code_builder: dependency: transitive description: name: code_builder - url: "https://pub.dartlang.org" + sha256: f692079e25e7869c14132d39f223f8eec9830eb76131925143b2129c4bb01b37 + url: "https://pub.dev" source: hosted - version: "4.1.0" + version: "4.10.0" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" source: hosted - version: "1.16.0" + version: "1.18.0" convert: dependency: transitive description: name: convert - url: "https://pub.dartlang.org" + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.1.1" crypto: dependency: transitive description: name: crypto - url: "https://pub.dartlang.org" + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.0.3" dart_style: dependency: transitive description: name: dart_style - url: "https://pub.dartlang.org" + sha256: "99e066ce75c89d6b29903d788a7bb9369cf754f7b24bf70bf4b6d6d6b26853b9" + url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.3.6" dartlin: dependency: "direct main" description: name: dartlin - url: "https://pub.dartlang.org" + sha256: "80764ff3d1801a086c2b802bd39ff6d306e783710741fab8e9981d2ba5ad68a1" + url: "https://pub.dev" source: hosted - version: "0.6.2" + version: "0.6.3" dashbook: dependency: "direct dev" description: name: dashbook - url: "https://pub.dartlang.org" + sha256: "2c3eb8d5b9f0d453c53d130375fc71e0b1ae25f1994506d7275f0f516e16327f" + url: "https://pub.dev" source: hosted - version: "0.1.5" + version: "0.1.15" device_frame: dependency: transitive description: name: device_frame - url: "https://pub.dartlang.org" + sha256: d031a06f5d6f4750009672db98a5aa1536aa4a231713852469ce394779a23d75 + url: "https://pub.dev" source: hosted - version: "0.4.2" + version: "1.2.0" dio: dependency: "direct main" description: name: dio - url: "https://pub.dartlang.org" + sha256: e17f6b3097b8c51b72c74c9f071a605c47bcc8893839bd66732457a5ebe73714 + url: "https://pub.dev" + source: hosted + version: "5.5.0+1" + dio_web_adapter: + dependency: transitive + description: + name: dio_web_adapter + sha256: "36c5b2d79eb17cdae41e974b7a8284fec631651d2a6f39a8a2ff22327e90aeac" + url: "https://pub.dev" source: hosted - version: "4.0.3" + version: "1.0.1" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted version: "1.3.1" ffi: dependency: transitive description: name: ffi - url: "https://pub.dartlang.org" + sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21" + url: "https://pub.dev" source: hosted - version: "1.1.2" + version: "2.1.2" file: dependency: transitive description: name: file - url: "https://pub.dartlang.org" + sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" + url: "https://pub.dev" source: hosted - version: "6.1.2" - firebase: - dependency: transitive - description: - name: firebase - url: "https://pub.dartlang.org" - source: hosted - version: "9.0.2" + version: "7.0.0" firebase_analytics: dependency: "direct main" description: name: firebase_analytics - url: "https://pub.dartlang.org" + sha256: "2017da2cb0745fa912e13aadfc94e49691796cf6b7ed37edbca2a2388713da11" + url: "https://pub.dev" source: hosted - version: "8.3.4" + version: "11.2.0" firebase_analytics_platform_interface: dependency: transitive description: name: firebase_analytics_platform_interface - url: "https://pub.dartlang.org" + sha256: "4ea00fe31ff74c92c613e082193b55bd21f0653b536dd77cc1ba4cf60771d214" + url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "4.2.0" firebase_analytics_web: dependency: transitive description: name: firebase_analytics_web - url: "https://pub.dartlang.org" + sha256: e5ce84f0c4e6fb8f8ca673d009445938a61845d8fa6b42c11913d5bbdbedf300 + url: "https://pub.dev" source: hosted - version: "0.3.0+1" + version: "0.5.9" firebase_core: dependency: "direct main" description: name: firebase_core - url: "https://pub.dartlang.org" + sha256: "5159984ce9b70727473eb388394650677c02c925aaa6c9439905e1f30966a4d5" + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "3.2.0" firebase_core_platform_interface: dependency: transitive description: name: firebase_core_platform_interface - url: "https://pub.dartlang.org" + sha256: "1003a5a03a61fc9a22ef49f37cbcb9e46c86313a7b2e7029b9390cf8c6fc32cb" + url: "https://pub.dev" source: hosted - version: "4.1.0" + version: "5.1.0" firebase_core_web: dependency: transitive description: name: firebase_core_web - url: "https://pub.dartlang.org" + sha256: "23509cb3cddfb3c910c143279ac3f07f06d3120f7d835e4a5d4b42558e978712" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "2.17.3" fixnum: dependency: transitive description: name: fixnum - url: "https://pub.dartlang.org" + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "1.1.0" flame: dependency: "direct main" description: name: flame - url: "https://pub.dartlang.org" + sha256: "79133dc46a3ff870950f41d0dc1598414e7bd7ae2c29bd9f0a9de208d9a70cb7" + url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "1.18.0" flame_audio: dependency: "direct main" description: name: flame_audio - url: "https://pub.dartlang.org" + sha256: "32e5788945469cebb807e741027e645a737e2618afc9b682e7f48607e0637f48" + url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "2.10.2" flame_lint: dependency: "direct dev" description: name: flame_lint - url: "https://pub.dartlang.org" + sha256: "69f30090f947a45948c0d8c7205f8ffa4b9745360d427d2de98bc69def9b7c42" + url: "https://pub.dev" source: hosted - version: "0.0.1" + version: "1.2.0" flame_splash_screen: dependency: "direct main" description: name: flame_splash_screen - url: "https://pub.dartlang.org" + sha256: "64e733b2df309638be908c2f699bd9b4ec1a580f33ac64050cf1740b8d60caf2" + url: "https://pub.dev" source: hosted - version: "0.1.0" + version: "0.3.0" flutter: dependency: "direct main" description: flutter @@ -318,30 +415,26 @@ packages: dependency: transitive description: name: flutter_colorpicker - url: "https://pub.dartlang.org" + sha256: "969de5f6f9e2a570ac660fb7b501551451ea2a1ab9e2097e89475f60e07816ea" + url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "1.1.0" flutter_launcher_icons: dependency: "direct dev" description: name: flutter_launcher_icons - url: "https://pub.dartlang.org" + sha256: "526faf84284b86a4cb36d20a5e45147747b7563d921373d4ee0559c54fcdbcea" + url: "https://pub.dev" source: hosted - version: "0.9.2" + version: "0.13.1" flutter_markdown: dependency: transitive description: name: flutter_markdown - url: "https://pub.dartlang.org" + sha256: "04c4722cc36ec5af38acc38ece70d22d3c2123c61305d555750a091517bbe504" + url: "https://pub.dev" source: hosted - version: "0.6.8" - flutter_svg: - dependency: transitive - description: - name: flutter_svg - url: "https://pub.dartlang.org" - source: hosted - version: "0.22.0" + version: "0.6.23" flutter_test: dependency: "direct dev" description: flutter @@ -356,345 +449,394 @@ packages: dependency: transitive description: name: freezed_annotation - url: "https://pub.dartlang.org" + sha256: c2e2d632dd9b8a2b7751117abcfc2b4888ecfe181bd9fca7170d9ef02e595fe2 + url: "https://pub.dev" source: hosted - version: "0.14.3" + version: "2.4.4" frontend_server_client: dependency: transitive description: name: frontend_server_client - url: "https://pub.dartlang.org" + sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694 + url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "4.0.0" glob: dependency: transitive description: name: glob - url: "https://pub.dartlang.org" + sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" + url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "2.1.2" google_mobile_ads: dependency: "direct main" description: name: google_mobile_ads - url: "https://pub.dartlang.org" + sha256: e2d18992d30b2be77cb6976b931112fc3c4612feffb5eb7a8b036bd7a64934da + url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "5.1.0" graphs: dependency: transitive description: name: graphs - url: "https://pub.dartlang.org" + sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19 + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.3.1" http: dependency: transitive description: name: http - url: "https://pub.dartlang.org" + sha256: "761a297c042deedc1ffbb156d6e2af13886bb305c2a343a4d972504cd67dd938" + url: "https://pub.dev" source: hosted - version: "0.13.4" + version: "1.2.1" http_multi_server: dependency: transitive description: name: http_multi_server - url: "https://pub.dartlang.org" + sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" + url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.2.1" http_parser: dependency: transitive description: name: http_parser - url: "https://pub.dartlang.org" + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" source: hosted - version: "4.0.0" + version: "4.0.2" image: dependency: transitive description: name: image - url: "https://pub.dartlang.org" + sha256: "2237616a36c0d69aef7549ab439b833fb7f9fb9fc861af2cc9ac3eedddd69ca8" + url: "https://pub.dev" source: hosted - version: "3.0.8" + version: "4.2.0" io: dependency: transitive description: name: io - url: "https://pub.dartlang.org" + sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" + url: "https://pub.dev" source: hosted - version: "1.0.3" + version: "1.0.4" js: dependency: transitive description: name: js - url: "https://pub.dartlang.org" + sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf + url: "https://pub.dev" source: hosted - version: "0.6.4" + version: "0.7.1" json_annotation: dependency: "direct main" description: name: json_annotation - url: "https://pub.dartlang.org" + sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1" + url: "https://pub.dev" source: hosted - version: "4.3.0" + version: "4.9.0" json_serializable: dependency: "direct dev" description: name: json_serializable - url: "https://pub.dartlang.org" + sha256: ea1432d167339ea9b5bb153f0571d0039607a873d6e04e0117af043f14a1fd4b + url: "https://pub.dev" + source: hosted + version: "6.8.0" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" + url: "https://pub.dev" + source: hosted + version: "10.0.5" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" + url: "https://pub.dev" + source: hosted + version: "3.0.5" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" + lints: + dependency: transitive + description: + name: lints + sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290 + url: "https://pub.dev" source: hosted - version: "6.0.1" + version: "3.0.0" logging: dependency: transitive description: name: logging - url: "https://pub.dartlang.org" + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + macros: + dependency: transitive + description: + name: macros + sha256: a8403c89b36483b4cbf9f1fcd24562f483cb34a5c9bf101cf2b0d8a083cf1239 + url: "https://pub.dev" source: hosted - version: "1.0.2" + version: "0.1.0-main.5" markdown: dependency: transitive description: name: markdown - url: "https://pub.dartlang.org" + sha256: ef2a1298144e3f985cc736b22e0ccdaf188b5b3970648f2d9dc13efd1d9df051 + url: "https://pub.dev" source: hosted - version: "4.0.1" + version: "7.2.2" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + url: "https://pub.dev" source: hosted - version: "0.12.12" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - url: "https://pub.dartlang.org" + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + url: "https://pub.dev" source: hosted - version: "0.1.5" + version: "0.11.1" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: "25dfcaf170a0190f47ca6355bdd4552cb8924b430512ff0cafb8db9bd41fe33b" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.14.0" mime: dependency: transitive description: name: mime - url: "https://pub.dartlang.org" + sha256: "2e123074287cc9fd6c09de8336dae606d1ddb88d9ac47358826db698c176a1f2" + url: "https://pub.dev" source: hosted - version: "1.0.1" + version: "1.0.5" oktoast: dependency: "direct main" description: name: oktoast - url: "https://pub.dartlang.org" + sha256: f1366c5c793ddfb8f55bc6fc3e45db43c45debf173b765fb4c5ec096cbdeb84a + url: "https://pub.dev" source: hosted - version: "3.1.5" + version: "3.4.0" ordered_set: dependency: transitive description: name: ordered_set - url: "https://pub.dartlang.org" + sha256: "1bfaaaee0419e43ecc9eaebd410eb4bd5039657b72011de75ff3e2915c9aac60" + url: "https://pub.dev" source: hosted - version: "5.0.0" + version: "5.0.3" package_config: dependency: transitive description: name: package_config - url: "https://pub.dartlang.org" + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "2.1.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.2" - path_drawing: - dependency: transitive - description: - name: path_drawing - url: "https://pub.dartlang.org" - source: hosted - version: "0.5.1+1" - path_parsing: - dependency: transitive - description: - name: path_parsing - url: "https://pub.dartlang.org" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + url: "https://pub.dev" source: hosted - version: "0.2.1" + version: "1.9.0" path_provider: dependency: transitive description: name: path_provider - url: "https://pub.dartlang.org" + sha256: c9e7d3a4cd1410877472158bee69963a4579f78b68c65a2b7d40d1a7a88bb161 + url: "https://pub.dev" source: hosted - version: "2.0.7" + version: "2.1.3" path_provider_android: dependency: transitive description: name: path_provider_android - url: "https://pub.dartlang.org" + sha256: "30c5aa827a6ae95ce2853cdc5fe3971daaac00f6f081c419c013f7f57bff2f5e" + url: "https://pub.dev" source: hosted - version: "2.0.8" - path_provider_ios: + version: "2.2.7" + path_provider_foundation: dependency: transitive description: - name: path_provider_ios - url: "https://pub.dartlang.org" + name: path_provider_foundation + sha256: f234384a3fdd67f989b4d54a5d73ca2a6c422fa55ae694381ae0f4375cd1ea16 + url: "https://pub.dev" source: hosted - version: "2.0.7" + version: "2.4.0" path_provider_linux: dependency: transitive description: name: path_provider_linux - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.2" - path_provider_macos: - dependency: transitive - description: - name: path_provider_macos - url: "https://pub.dartlang.org" + sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 + url: "https://pub.dev" source: hosted - version: "2.0.3" + version: "2.2.1" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface - url: "https://pub.dartlang.org" + sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334" + url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.1.2" path_provider_windows: dependency: transitive description: name: path_provider_windows - url: "https://pub.dartlang.org" + sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7 + url: "https://pub.dev" source: hosted - version: "2.0.4" + version: "2.3.0" petitparser: dependency: transitive description: name: petitparser - url: "https://pub.dartlang.org" + sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27 + url: "https://pub.dev" source: hosted - version: "4.4.0" + version: "6.0.2" platform: dependency: transitive description: name: platform - url: "https://pub.dartlang.org" + sha256: "9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65" + url: "https://pub.dev" source: hosted - version: "3.1.0" + version: "3.1.5" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - url: "https://pub.dartlang.org" + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "2.1.8" pool: dependency: transitive description: name: pool - url: "https://pub.dartlang.org" - source: hosted - version: "1.5.0" - process: - dependency: transitive - description: - name: process - url: "https://pub.dartlang.org" + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.dev" source: hosted - version: "4.2.4" + version: "1.5.1" pub_semver: dependency: transitive description: name: pub_semver - url: "https://pub.dartlang.org" + sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.4" pubspec_parse: dependency: transitive description: name: pubspec_parse - url: "https://pub.dartlang.org" + sha256: c799b721d79eb6ee6fa56f00c04b472dcd44a30d258fac2174a6ec57302678f8 + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.3.0" shared_preferences: dependency: "direct main" description: name: shared_preferences - url: "https://pub.dartlang.org" + sha256: d3bbe5553a986e83980916ded2f0b435ef2e1893dfaa29d5a7a790d0eca12180 + url: "https://pub.dev" source: hosted - version: "2.0.9" + version: "2.2.3" shared_preferences_android: dependency: transitive description: name: shared_preferences_android - url: "https://pub.dartlang.org" + sha256: "93d0ec9dd902d85f326068e6a899487d1f65ffcd5798721a95330b26c8131577" + url: "https://pub.dev" source: hosted - version: "2.0.8" - shared_preferences_ios: + version: "2.2.3" + shared_preferences_foundation: dependency: transitive description: - name: shared_preferences_ios - url: "https://pub.dartlang.org" + name: shared_preferences_foundation + sha256: "0a8a893bf4fd1152f93fec03a415d11c27c74454d96e2318a7ac38dd18683ab7" + url: "https://pub.dev" source: hosted - version: "2.0.8" + version: "2.4.0" shared_preferences_linux: dependency: transitive description: name: shared_preferences_linux - url: "https://pub.dartlang.org" + sha256: "9f2cbcf46d4270ea8be39fa156d86379077c8a5228d9dfdb1164ae0bb93f1faa" + url: "https://pub.dev" source: hosted - version: "2.0.3" - shared_preferences_macos: - dependency: transitive - description: - name: shared_preferences_macos - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.2" + version: "2.3.2" shared_preferences_platform_interface: dependency: transitive description: name: shared_preferences_platform_interface - url: "https://pub.dartlang.org" + sha256: "22e2ecac9419b4246d7c22bfbbda589e3acf5c0351137d87dd2939d984d37c3b" + url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "2.3.2" shared_preferences_web: dependency: transitive description: name: shared_preferences_web - url: "https://pub.dartlang.org" + sha256: "9aee1089b36bd2aafe06582b7d7817fd317ef05fc30e6ba14bff247d0933042a" + url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "2.3.0" shared_preferences_windows: dependency: transitive description: name: shared_preferences_windows - url: "https://pub.dartlang.org" + sha256: "841ad54f3c8381c480d0c9b508b89a34036f512482c407e6df7a9c4aa2ef8f59" + url: "https://pub.dev" source: hosted - version: "2.0.3" + version: "2.3.2" shelf: dependency: transitive description: name: shelf - url: "https://pub.dartlang.org" + sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.4.1" shelf_web_socket: dependency: transitive description: name: shelf_web_socket - url: "https://pub.dartlang.org" + sha256: "073c147238594ecd0d193f3456a5fe91c4b0abbcc68bf5cd95b36c4e194ac611" + url: "https://pub.dev" source: hosted - version: "1.0.1" + version: "2.0.0" sky_engine: dependency: transitive description: flutter @@ -704,184 +846,282 @@ packages: dependency: transitive description: name: source_gen - url: "https://pub.dartlang.org" + sha256: "14658ba5f669685cd3d63701d01b31ea748310f7ab854e471962670abcf57832" + url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.5.0" source_helper: dependency: transitive description: name: source_helper - url: "https://pub.dartlang.org" + sha256: "6adebc0006c37dd63fe05bca0a929b99f06402fc95aa35bf36d67f5c06de01fd" + url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.3.4" source_span: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "1.10.0" + sprintf: + dependency: transitive + description: + name: sprintf + sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23" + url: "https://pub.dev" + source: hosted + version: "7.0.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.2" stream_transform: dependency: transitive description: name: stream_transform - url: "https://pub.dartlang.org" + sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" + url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.2.0" synchronized: dependency: transitive description: name: synchronized - url: "https://pub.dartlang.org" + sha256: "539ef412b170d65ecdafd780f924e5be3f60032a1128df156adad6c5b373d558" + url: "https://pub.dev" source: hosted - version: "3.0.0" + version: "3.1.0+1" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: "2419f20b0c8677b2d67c8ac4d1ac7372d862dc6c460cdbb052b40155408cd794" + url: "https://pub.dev" source: hosted - version: "0.4.12" + version: "0.7.1" timing: dependency: transitive description: name: timing - url: "https://pub.dartlang.org" + sha256: "70a3b636575d4163c477e6de42f247a23b315ae20e86442bebe32d3cabf61c32" + url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "1.0.1" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.3.2" url_launcher: dependency: "direct main" description: name: url_launcher - url: "https://pub.dartlang.org" + sha256: "21b704ce5fa560ea9f3b525b43601c678728ba46725bab9b01187b4831377ed3" + url: "https://pub.dev" + source: hosted + version: "6.3.0" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + sha256: ceb2625f0c24ade6ef6778d1de0b2e44f2db71fded235eb52295247feba8c5cf + url: "https://pub.dev" source: hosted - version: "6.0.15" + version: "6.3.3" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + sha256: e43b677296fadce447e987a2f519dcf5f6d1e527dc35d01ffab4fff5b8a7063e + url: "https://pub.dev" + source: hosted + version: "6.3.1" url_launcher_linux: dependency: transitive description: name: url_launcher_linux - url: "https://pub.dartlang.org" + sha256: ab360eb661f8879369acac07b6bb3ff09d9471155357da8443fd5d3cf7363811 + url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "3.1.1" url_launcher_macos: dependency: transitive description: name: url_launcher_macos - url: "https://pub.dartlang.org" + sha256: "9a1a42d5d2d95400c795b2914c36fdcb525870c752569438e4ebb09a2b5d90de" + url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "3.2.0" url_launcher_platform_interface: dependency: transitive description: name: url_launcher_platform_interface - url: "https://pub.dartlang.org" + sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029" + url: "https://pub.dev" source: hosted - version: "2.0.4" + version: "2.3.2" url_launcher_web: dependency: transitive description: name: url_launcher_web - url: "https://pub.dartlang.org" + sha256: "8d9e750d8c9338601e709cd0885f95825086bd8b642547f26bda435aade95d8a" + url: "https://pub.dev" source: hosted - version: "2.0.4" + version: "2.3.1" url_launcher_windows: dependency: transitive description: name: url_launcher_windows - url: "https://pub.dartlang.org" + sha256: ecf9725510600aa2bb6d7ddabe16357691b6d2805f66216a97d1b881e21beff7 + url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "3.1.1" uuid: dependency: transitive description: name: uuid - url: "https://pub.dartlang.org" + sha256: "83d37c7ad7aaf9aa8e275490669535c8080377cfa7a7004c24dfac53afffaa90" + url: "https://pub.dev" source: hosted - version: "3.0.5" + version: "4.4.2" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.4" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "7475cb4dd713d57b6f7464c0e13f06da0d535d8b2067e188962a59bac2cf280b" + url: "https://pub.dev" + source: hosted + version: "14.2.2" watcher: dependency: transitive description: name: watcher - url: "https://pub.dartlang.org" + sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" + url: "https://pub.dev" source: hosted - version: "1.0.1" + version: "1.1.0" + web: + dependency: transitive + description: + name: web + sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27" + url: "https://pub.dev" + source: hosted + version: "0.5.1" + web_socket: + dependency: transitive + description: + name: web_socket + sha256: "24301d8c293ce6fe327ffe6f59d8fd8834735f0ec36e4fd383ec7ff8a64aa078" + url: "https://pub.dev" + source: hosted + version: "0.1.5" web_socket_channel: dependency: transitive description: name: web_socket_channel - url: "https://pub.dartlang.org" + sha256: a2d56211ee4d35d9b344d9d4ce60f362e4f5d1aafb988302906bd732bc731276 + url: "https://pub.dev" source: hosted - version: "2.1.0" - win32: + version: "3.0.0" + webview_flutter: dependency: transitive description: - name: win32 - url: "https://pub.dartlang.org" + name: webview_flutter + sha256: "6869c8786d179f929144b4a1f86e09ac0eddfe475984951ea6c634774c16b522" + url: "https://pub.dev" source: hosted - version: "2.3.0" + version: "4.8.0" + webview_flutter_android: + dependency: transitive + description: + name: webview_flutter_android + sha256: f42447ca49523f11d8f70abea55ea211b3cafe172dd7a0e7ac007bb35dd356dc + url: "https://pub.dev" + source: hosted + version: "3.16.4" + webview_flutter_platform_interface: + dependency: transitive + description: + name: webview_flutter_platform_interface + sha256: d937581d6e558908d7ae3dc1989c4f87b786891ab47bb9df7de548a151779d8d + url: "https://pub.dev" + source: hosted + version: "2.10.0" + webview_flutter_wkwebview: + dependency: transitive + description: + name: webview_flutter_wkwebview + sha256: "9c62cc46fa4f2d41e10ab81014c1de470a6c6f26051a2de32111b2ee55287feb" + url: "https://pub.dev" + source: hosted + version: "3.14.0" xdg_directories: dependency: transitive description: name: xdg_directories - url: "https://pub.dartlang.org" + sha256: faea9dee56b520b55a566385b84f2e8de55e7496104adada9962e0bd11bcff1d + url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "1.0.4" xml: dependency: transitive description: name: xml - url: "https://pub.dartlang.org" + sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226 + url: "https://pub.dev" source: hosted - version: "5.3.1" + version: "6.5.0" yaml: dependency: transitive description: name: yaml - url: "https://pub.dartlang.org" + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" + url: "https://pub.dev" source: hosted - version: "3.1.0" + version: "3.1.2" sdks: - dart: ">=2.17.0-0 <3.0.0" - flutter: ">=2.5.0" + dart: ">=3.4.0 <4.0.0" + flutter: ">=3.22.0" diff --git a/game/pubspec.yaml b/game/pubspec.yaml index 6cd10a2..321b22d 100644 --- a/game/pubspec.yaml +++ b/game/pubspec.yaml @@ -4,32 +4,33 @@ version: 0.4.0 publish_to: none environment: - sdk: ">=2.14.0 <3.0.0" + sdk: ">=3.3.0 <4.0.0" + flutter: ">=3.19.0" dependencies: + dartlin: ^0.6.3 + dio: ^5.5.0+1 + firebase_analytics: ^11.2.0 + firebase_core: ^3.2.0 + flame: ^1.18.0 + flame_audio: ^2.10.2 + flame_splash_screen: ^0.3.0 flutter: sdk: flutter - flame: 1.0.0 - flame_audio: 1.0.0 - json_annotation: 4.3.0 - flame_splash_screen: 0.1.0 - shared_preferences: 2.0.9 - dio: 4.0.3 - url_launcher: 6.0.15 - google_mobile_ads: 1.0.0 - oktoast: 3.1.5 - firebase_core: 1.10.0 - firebase_analytics: 8.3.4 - dartlin: 0.6.2 + google_mobile_ads: ^5.1.0 + json_annotation: ^4.9.0 + oktoast: ^3.4.0 + shared_preferences: ^2.2.3 + url_launcher: ^6.3.0 dev_dependencies: + build_runner: ^2.4.11 + dashbook: ^0.1.15 + flame_lint: ^1.2.0 + flutter_launcher_icons: ^0.13.1 flutter_test: sdk: flutter - flame_lint: 0.0.1 - build_runner: 2.1.5 - json_serializable: 6.0.1 - dashbook: 0.1.5 - flutter_launcher_icons: 0.9.2 + json_serializable: ^6.8.0 flutter_icons: android: "launcher_icon" From e2d4d363a51d362efdf12bf2e4b2b69c0c751973 Mon Sep 17 00:00:00 2001 From: Luan Nico Date: Mon, 15 Jul 2024 23:19:29 -0400 Subject: [PATCH 2/2] Fix camera for some of the components --- game/lib/game/components/player.dart | 3 ++- game/lib/game/game.dart | 16 +++++++--------- game/lib/game/util.dart | 10 +++++++++- game/lib/main.dart | 5 ++++- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/game/lib/game/components/player.dart b/game/lib/game/components/player.dart index 6a76b1e..2425bd2 100644 --- a/game/lib/game/components/player.dart +++ b/game/lib/game/components/player.dart @@ -316,7 +316,8 @@ class PlayerCameraFollower extends ReadOnlyPositionProvider { @override Vector2 get position { - _position.x = player.position.x - game.size.x / 3; + _position.x = player.position.x - game.size.x / 3 + game.size.x / 2; + _position.y = game.size.y / 2; return _position; } } diff --git a/game/lib/game/game.dart b/game/lib/game/game.dart index 5486f73..d3f1e6d 100644 --- a/game/lib/game/game.dart +++ b/game/lib/game/game.dart @@ -69,7 +69,6 @@ class MyGame extends FlameGame with TapDetector { // TODO(luan): figure this out // noClip: true, ); - camera.moveBy(-screenSize / 2); await preStart(); } @@ -86,9 +85,7 @@ class MyGame extends FlameGame with TapDetector { coins = 0; hasUsedExtraLife = false; - // TODO(luan): figure out how to do this now - // ignore: invalid_use_of_internal_member - children.clear(); + world.clear(); if (isFirstTime) { showTutorial = 0; await _addBg(Background.tutorial(lastGeneratedX)); @@ -97,12 +94,14 @@ class MyGame extends FlameGame with TapDetector { await _addBg(Background.plains(lastGeneratedX)); } - world.add(powerups = Powerups()); - await world.add(player = Player()); + await world.addAll([ + powerups = Powerups(), + player = Player(), + ]); setupCamera(); await world.add(wall = Wall(firstX - size.x)); - await camera.viewport.add(Stars()); + camera.backdrop = Stars(); rotationManager = RotationManager(); } @@ -110,7 +109,6 @@ class MyGame extends FlameGame with TapDetector { void setupCamera() { camera.follow( PlayerCameraFollower(game: this, player: player), - horizontalOnly: true, ); } @@ -305,4 +303,4 @@ class MyGame extends FlameGame with TapDetector { // TODO(luan): implement camera shake // camera.shake(); } -} +} \ No newline at end of file diff --git a/game/lib/game/util.dart b/game/lib/game/util.dart index ddeb50a..2571b54 100644 --- a/game/lib/game/util.dart +++ b/game/lib/game/util.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'dart:math' as math; import 'package:dartlin/dartlin.dart'; +import 'package:flame/components.dart'; import 'package:flame/game.dart'; import 'package:flutter/widgets.dart'; import 'package:gravitational_waves/game/palette.dart'; @@ -9,12 +10,13 @@ import 'package:shared_preferences/shared_preferences.dart'; final R = math.Random(); -const ENABLE_AUDIO = true; +const ENABLE_AUDIO = false; const DEBUG = false; const CHECK_PLAYER_ID = false; const ENABLE_REVAMP = true; const ENABLE_ADS = false; const ENABLE_FIREBASE = false; +const ENABLE_SPLASH = false; const BLOCK_SIZE = 16.0; const BLOCK_SIZE_INT = 16; @@ -63,3 +65,9 @@ class Fonts { (it) => it.copyWith(fontSize: 24.0, color: Palette.hud.color), ); } + +extension Clear on Component { + void clear() { + removeAll(children); + } +} \ No newline at end of file diff --git a/game/lib/main.dart b/game/lib/main.dart index 57cc07b..a99dd52 100644 --- a/game/lib/main.dart +++ b/game/lib/main.dart @@ -66,6 +66,7 @@ void main() async { runApp( OKToast( child: MaterialApp( + initialRoute: ENABLE_SPLASH ? '/' : '/game', routes: { '/': (BuildContext ctx) => FlameSplashScreen( theme: FlameSplashTheme.dark, @@ -76,7 +77,9 @@ void main() async { ); }, onFinish: (BuildContext context) { - Navigator.pushNamed(context, '/game'); + if (ENABLE_SPLASH) { + Navigator.pushNamed(context, '/game'); + } }, ), '/options': (BuildContext ctx) =>