diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..ae08714 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/lib/Bug.dart b/lib/bug.dart similarity index 96% rename from lib/Bug.dart rename to lib/bug.dart index 814c1ee..320c410 100644 --- a/lib/Bug.dart +++ b/lib/bug.dart @@ -1,4 +1,4 @@ -import 'package:firo_runner/MovingObject.dart'; +import 'package:firo_runner/moving_object.dart'; import 'package:firo_runner/main.dart'; import 'package:flame/components.dart'; diff --git a/lib/BugHolder.dart b/lib/bug_holder.dart similarity index 92% rename from lib/BugHolder.dart rename to lib/bug_holder.dart index 1cca3c4..2dd9a6c 100644 --- a/lib/BugHolder.dart +++ b/lib/bug_holder.dart @@ -1,14 +1,15 @@ import 'dart:math'; -import 'package:firo_runner/Platform.dart'; +import 'package:firo_runner/platform.dart'; +import 'package:flame/extensions.dart'; import 'package:flame/flame.dart'; -import 'Bug.dart'; -import 'main.dart'; +import 'package:firo_runner/bug.dart'; +import 'package:firo_runner/main.dart'; class BugHolder { - var bug; - var breaking; + late Image bug; + late Image breaking; Random random = Random(); late List> bugs = []; diff --git a/lib/CircuitBackground.dart b/lib/circuit_background.dart similarity index 94% rename from lib/CircuitBackground.dart rename to lib/circuit_background.dart index b157faf..093220c 100644 --- a/lib/CircuitBackground.dart +++ b/lib/circuit_background.dart @@ -1,8 +1,8 @@ -import 'package:firo_runner/MovingObject.dart'; +import 'package:firo_runner/moving_object.dart'; import 'package:firo_runner/main.dart'; import 'package:flame/components.dart'; import 'package:flame/flame.dart'; -import 'package:flutter/material.dart'; +import 'package:flame/extensions.dart'; enum WindowState { first, @@ -15,14 +15,14 @@ enum WindowState { } class CircuitBackground extends MovingObject { - late var background; - late var windows0; - late var windows1; - late var windows2; - late var windows3; - late var windows4; - late var windows5; - late var windows6; + late Image background; + late Image windows0; + late Image windows1; + late Image windows2; + late Image windows3; + late Image windows4; + late Image windows5; + late Image windows6; late Sprite background1; late Sprite background2; @@ -140,7 +140,7 @@ class CircuitBackground extends MovingObject { gameRef.add(windowB); background1Position = Vector2(0, 0); background1Size = Vector2( - gameRef.size.y * (background!.width / background!.height), + gameRef.size.y * (background.width / background.height), gameRef.size.y); windowA.position = background1Position; windowA.size = background1Size; @@ -148,7 +148,7 @@ class CircuitBackground extends MovingObject { background2Position = Vector2(background1Position.x + background1Size.x - 1, 0); background2Size = Vector2( - gameRef.size.y * (background!.width / background!.height), + gameRef.size.y * (background.width / background.height), gameRef.size.y); windowB.position = background2Position; windowB.size = background2Size; diff --git a/lib/Coin.dart b/lib/coin.dart similarity index 81% rename from lib/Coin.dart rename to lib/coin.dart index 755e934..bdd3a57 100644 --- a/lib/Coin.dart +++ b/lib/coin.dart @@ -1,4 +1,4 @@ -import 'package:firo_runner/MovingObject.dart'; +import 'package:firo_runner/moving_object.dart'; import 'package:firo_runner/main.dart'; import 'package:flame/components.dart'; @@ -28,8 +28,8 @@ class Coin extends MovingObject { var platform = gameRef.platformHolder.l1; setSize( - gameRef.blockSize * (platform!.width / platform!.height / 14), - gameRef.blockSize * (platform!.width / platform!.height / 14), + gameRef.blockSize * (platform.width / platform.height / 14), + gameRef.blockSize * (platform.width / platform.height / 14), ); } diff --git a/lib/CoinHolder.dart b/lib/coin_holder.dart similarity index 93% rename from lib/CoinHolder.dart rename to lib/coin_holder.dart index e60c2d9..8fd3902 100644 --- a/lib/CoinHolder.dart +++ b/lib/coin_holder.dart @@ -2,11 +2,12 @@ import 'dart:math'; import 'package:flame/flame.dart'; -import 'Coin.dart'; -import 'main.dart'; +import 'package:firo_runner/coin.dart'; +import 'package:firo_runner/main.dart'; +import 'package:flame/extensions.dart'; class CoinHolder { - var coin; + late Image coin; Random random = Random(); late List> coins = []; diff --git a/lib/GameState.dart b/lib/game_state.dart similarity index 100% rename from lib/GameState.dart rename to lib/game_state.dart diff --git a/lib/main.dart b/lib/main.dart index 736cc51..754a1c8 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,12 +1,12 @@ import 'dart:math'; -import 'package:firo_runner/BugHolder.dart'; -import 'package:firo_runner/CircuitBackground.dart'; -import 'package:firo_runner/CoinHolder.dart'; -import 'package:firo_runner/GameState.dart'; -import 'package:firo_runner/PlatformHolder.dart'; -import 'package:firo_runner/Wire.dart'; -import 'package:firo_runner/WireHolder.dart'; +import 'package:firo_runner/bug_holder.dart'; +import 'package:firo_runner/circuit_background.dart'; +import 'package:firo_runner/coin_holder.dart'; +import 'package:firo_runner/game_state.dart'; +import 'package:firo_runner/platform_holder.dart'; +import 'package:firo_runner/wire.dart'; +import 'package:firo_runner/wire_holder.dart'; import 'package:flame/components.dart'; import 'package:flame/extensions.dart'; import 'package:flame/flame.dart'; @@ -16,12 +16,12 @@ import 'package:flame/keyboard.dart'; import 'package:flame_audio/flame_audio.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'Bug.dart'; -import 'Coin.dart'; -import 'Runner.dart'; +import 'package:firo_runner/bug.dart'; +import 'package:firo_runner/coin.dart'; +import 'package:firo_runner/runner.dart'; import 'package:flutter/foundation.dart' show kIsWeb; -const COLOR = const Color(0xFFDDC0A3); +const COLOR = Color(0xFFDDC0A3); const LEVEL2 = 10000000; const LEVEL3 = 20000000; @@ -46,7 +46,7 @@ void main() async { class MyGame extends BaseGame with PanDetector, TapDetector, KeyboardEvents { TextPaint textPaint = TextPaint( - config: TextPaintConfig(fontSize: 48.0), + config: const TextPaintConfig(fontSize: 48.0), ); late CircuitBackground circuitBackground; @@ -161,7 +161,7 @@ class MyGame extends BaseGame with PanDetector, TapDetector, KeyboardEvents { } runner.sprite.animation!.reset(); shouldReset = false; - this.components.clear(); + components.clear(); setUp(); } @@ -218,15 +218,14 @@ class MyGame extends BaseGame with PanDetector, TapDetector, KeyboardEvents { wireHolder.update(dt); bugHolder.update(dt); if (shouldReset) { - print("should reset"); reset(); } } @override - void onResize(Vector2 size) { - super.onResize(size); - blockSize = size.y / 9; + void onResize(Vector2 canvasSize) { + super.onResize(canvasSize); + blockSize = canvasSize.y / 9; } // Mobile controls diff --git a/lib/MovingObject.dart b/lib/moving_object.dart similarity index 100% rename from lib/MovingObject.dart rename to lib/moving_object.dart diff --git a/lib/Platform.dart b/lib/platform.dart similarity index 95% rename from lib/Platform.dart rename to lib/platform.dart index 1cc9973..24dee9e 100644 --- a/lib/Platform.dart +++ b/lib/platform.dart @@ -1,6 +1,6 @@ import 'dart:math'; -import 'package:firo_runner/MovingObject.dart'; +import 'package:firo_runner/moving_object.dart'; import 'package:firo_runner/main.dart'; import 'package:flame/components.dart'; @@ -70,8 +70,8 @@ class Platform extends MovingObject { setSize( gameRef.blockSize * - (gameRef.platformHolder.l1!.width / - gameRef.platformHolder.l1!.height / + (gameRef.platformHolder.l1.width / + gameRef.platformHolder.l1.height / 5), gameRef.blockSize, ); diff --git a/lib/PlatformHolder.dart b/lib/platform_holder.dart similarity index 93% rename from lib/PlatformHolder.dart rename to lib/platform_holder.dart index a57c410..5b4ba36 100644 --- a/lib/PlatformHolder.dart +++ b/lib/platform_holder.dart @@ -2,17 +2,18 @@ import 'dart:math'; import 'package:firo_runner/main.dart'; import 'package:flame/flame.dart'; -import 'Platform.dart'; +import 'package:firo_runner/platform.dart'; +import 'package:flame/extensions.dart'; class PlatformHolder { - var l1; - var l2; - var m1; - var m2; - var r1; - var r2; - var o1; - var o2; + late Image l1; + late Image l2; + late Image m1; + late Image m2; + late Image r1; + late Image r2; + late Image o1; + late Image o2; late List> platforms = []; Random random = Random(); diff --git a/lib/Runner.dart b/lib/runner.dart similarity index 95% rename from lib/Runner.dart rename to lib/runner.dart index 002a08c..aea1cf2 100644 --- a/lib/Runner.dart +++ b/lib/runner.dart @@ -1,10 +1,11 @@ -import 'package:firo_runner/Bug.dart'; -import 'package:firo_runner/Coin.dart'; -import 'package:firo_runner/Wire.dart'; +import 'package:firo_runner/bug.dart'; +import 'package:firo_runner/coin.dart'; +import 'package:firo_runner/wire.dart'; import 'package:firo_runner/main.dart'; import 'package:flame/effects.dart'; +import 'package:flame/extensions.dart'; import 'package:flutter/material.dart'; -import 'Platform.dart'; +import 'package:firo_runner/platform.dart'; import 'package:flame/components.dart'; @@ -16,7 +17,7 @@ enum RunnerState { float, fall, die, - electro, + electrocute, glitch, } @@ -26,7 +27,7 @@ class Runner extends Component with HasGameRef { int level = 4; String previousState = "run"; var runnerPosition = Vector2(0, 0); - var runnerSize; + late Vector2 runnerSize; bool dead = false; void setUp() { @@ -72,7 +73,6 @@ class Runner extends Component with HasGameRef { return; } previousState = runnerState; - print(event); switch (event) { case "jump": runnerState = event; @@ -90,7 +90,7 @@ class Runner extends Component with HasGameRef { }, )); break; - case "doublejump": + case "double_jump": if (level - 1 < 0) { break; } @@ -157,12 +157,12 @@ class Runner extends Component with HasGameRef { sprite.current = RunnerState.die; gameRef.die(); break; - case "electro": + case "electrocute": if (dead) { return; } runnerState = event; - sprite.current = RunnerState.electro; + sprite.current = RunnerState.electrocute; gameRef.die(); break; case "glitch": @@ -182,13 +182,12 @@ class Runner extends Component with HasGameRef { if (gameRef.gameState.isPaused) { return; } - print(input); switch (input) { case "up": if (runnerState == "run") { event("jump"); } else if (runnerState == "float" && previousState == "jump") { - event("doublejump"); + event("double_jump"); } else if (runnerState == "duck") { event("run"); } @@ -277,7 +276,6 @@ class Runner extends Component with HasGameRef { if (coinLevel[i].intersect(runnerRect) != "none") { gameRef.gameState.numCoins++; gameRef.coinHolder.remove(coinLevel, i); - print(gameRef.gameState.numCoins); continue; } i++; @@ -287,7 +285,7 @@ class Runner extends Component with HasGameRef { for (List wireLevel in gameRef.wireHolder.wires) { for (int i = 0; i < wireLevel.length; i++) { if (wireLevel[i].intersect(runnerRect) != "none") { - event("electro"); + event("electrocute"); return; } } @@ -425,7 +423,7 @@ class Runner extends Component with HasGameRef { RunnerState.float: floating, RunnerState.fall: falling, RunnerState.die: dying, - RunnerState.electro: dyingElectrocuted, + RunnerState.electrocute: dyingElectrocuted, RunnerState.glitch: dyingGlitch, }, current: RunnerState.run, diff --git a/lib/Wire.dart b/lib/wire.dart similarity index 94% rename from lib/Wire.dart rename to lib/wire.dart index 59e1244..78d7b90 100644 --- a/lib/Wire.dart +++ b/lib/wire.dart @@ -1,4 +1,4 @@ -import 'package:firo_runner/MovingObject.dart'; +import 'package:firo_runner/moving_object.dart'; import 'package:firo_runner/main.dart'; import 'package:flame/components.dart'; diff --git a/lib/WireHolder.dart b/lib/wire_holder.dart similarity index 93% rename from lib/WireHolder.dart rename to lib/wire_holder.dart index ad8153a..09cfe72 100644 --- a/lib/WireHolder.dart +++ b/lib/wire_holder.dart @@ -1,13 +1,14 @@ import 'dart:math'; -import 'package:firo_runner/Platform.dart'; +import 'package:firo_runner/platform.dart'; import 'package:flame/flame.dart'; -import 'Wire.dart'; -import 'main.dart'; +import 'package:firo_runner/wire.dart'; +import 'package:firo_runner/main.dart'; +import 'package:flame/extensions.dart'; class WireHolder { - var wire; + late Image wire; Random random = Random(); late List> wires = []; diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index d38195a..e71a16d 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -2,6 +2,8 @@ // Generated file. Do not edit. // +// clang-format off + #include "generated_plugin_registrant.h" diff --git a/linux/flutter/generated_plugin_registrant.h b/linux/flutter/generated_plugin_registrant.h index 9bf7478..e0f0a47 100644 --- a/linux/flutter/generated_plugin_registrant.h +++ b/linux/flutter/generated_plugin_registrant.h @@ -2,6 +2,8 @@ // Generated file. Do not edit. // +// clang-format off + #ifndef GENERATED_PLUGIN_REGISTRANT_ #define GENERATED_PLUGIN_REGISTRANT_ diff --git a/pubspec.lock b/pubspec.lock index d72f0a9..7e37756 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.6.1" + version: "2.8.1" audioplayers: dependency: transitive description: @@ -35,7 +35,7 @@ packages: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" clock: dependency: transitive description: @@ -104,6 +104,13 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" flutter_test: dependency: "direct dev" description: flutter @@ -135,6 +142,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.6.3" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" matcher: dependency: transitive description: @@ -148,7 +162,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.7.0" ordered_set: dependency: transitive description: @@ -279,7 +293,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.4.2" typed_data: dependency: transitive description: @@ -307,7 +321,7 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.2.8" + version: "2.2.9" xdg_directories: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index a3acb6c..2f9edf8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -32,6 +32,7 @@ dependencies: cupertino_icons: ^1.0.2 dev_dependencies: + flutter_lints: ^1.0.4 flutter_test: sdk: flutter