Upgraded the code to support Flutter SDK 2.5 and Dart 2.14. If you have previous builds please delete your build file, run 'flutter upgrade' on the stable flutter channel and also run 'flutter clean' in the project directory.

This commit is contained in:
Marco Salazar 2021-09-08 15:44:12 -06:00
parent 99e505f062
commit 88207b67ce
18 changed files with 127 additions and 78 deletions

29
analysis_options.yaml Normal file
View File

@ -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

View File

@ -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:firo_runner/main.dart';
import 'package:flame/components.dart'; import 'package:flame/components.dart';

View File

@ -1,14 +1,15 @@
import 'dart:math'; 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 'package:flame/flame.dart';
import 'Bug.dart'; import 'package:firo_runner/bug.dart';
import 'main.dart'; import 'package:firo_runner/main.dart';
class BugHolder { class BugHolder {
var bug; late Image bug;
var breaking; late Image breaking;
Random random = Random(); Random random = Random();
late List<List<Bug>> bugs = []; late List<List<Bug>> bugs = [];

View File

@ -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:firo_runner/main.dart';
import 'package:flame/components.dart'; import 'package:flame/components.dart';
import 'package:flame/flame.dart'; import 'package:flame/flame.dart';
import 'package:flutter/material.dart'; import 'package:flame/extensions.dart';
enum WindowState { enum WindowState {
first, first,
@ -15,14 +15,14 @@ enum WindowState {
} }
class CircuitBackground extends MovingObject { class CircuitBackground extends MovingObject {
late var background; late Image background;
late var windows0; late Image windows0;
late var windows1; late Image windows1;
late var windows2; late Image windows2;
late var windows3; late Image windows3;
late var windows4; late Image windows4;
late var windows5; late Image windows5;
late var windows6; late Image windows6;
late Sprite background1; late Sprite background1;
late Sprite background2; late Sprite background2;
@ -140,7 +140,7 @@ class CircuitBackground extends MovingObject {
gameRef.add(windowB); gameRef.add(windowB);
background1Position = Vector2(0, 0); background1Position = Vector2(0, 0);
background1Size = Vector2( background1Size = Vector2(
gameRef.size.y * (background!.width / background!.height), gameRef.size.y * (background.width / background.height),
gameRef.size.y); gameRef.size.y);
windowA.position = background1Position; windowA.position = background1Position;
windowA.size = background1Size; windowA.size = background1Size;
@ -148,7 +148,7 @@ class CircuitBackground extends MovingObject {
background2Position = background2Position =
Vector2(background1Position.x + background1Size.x - 1, 0); Vector2(background1Position.x + background1Size.x - 1, 0);
background2Size = Vector2( background2Size = Vector2(
gameRef.size.y * (background!.width / background!.height), gameRef.size.y * (background.width / background.height),
gameRef.size.y); gameRef.size.y);
windowB.position = background2Position; windowB.position = background2Position;
windowB.size = background2Size; windowB.size = background2Size;

View File

@ -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:firo_runner/main.dart';
import 'package:flame/components.dart'; import 'package:flame/components.dart';
@ -28,8 +28,8 @@ class Coin extends MovingObject {
var platform = gameRef.platformHolder.l1; var platform = gameRef.platformHolder.l1;
setSize( 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),
); );
} }

View File

@ -2,11 +2,12 @@ import 'dart:math';
import 'package:flame/flame.dart'; import 'package:flame/flame.dart';
import 'Coin.dart'; import 'package:firo_runner/coin.dart';
import 'main.dart'; import 'package:firo_runner/main.dart';
import 'package:flame/extensions.dart';
class CoinHolder { class CoinHolder {
var coin; late Image coin;
Random random = Random(); Random random = Random();
late List<List<Coin>> coins = []; late List<List<Coin>> coins = [];

View File

@ -1,12 +1,12 @@
import 'dart:math'; import 'dart:math';
import 'package:firo_runner/BugHolder.dart'; import 'package:firo_runner/bug_holder.dart';
import 'package:firo_runner/CircuitBackground.dart'; import 'package:firo_runner/circuit_background.dart';
import 'package:firo_runner/CoinHolder.dart'; import 'package:firo_runner/coin_holder.dart';
import 'package:firo_runner/GameState.dart'; import 'package:firo_runner/game_state.dart';
import 'package:firo_runner/PlatformHolder.dart'; import 'package:firo_runner/platform_holder.dart';
import 'package:firo_runner/Wire.dart'; import 'package:firo_runner/wire.dart';
import 'package:firo_runner/WireHolder.dart'; import 'package:firo_runner/wire_holder.dart';
import 'package:flame/components.dart'; import 'package:flame/components.dart';
import 'package:flame/extensions.dart'; import 'package:flame/extensions.dart';
import 'package:flame/flame.dart'; import 'package:flame/flame.dart';
@ -16,12 +16,12 @@ import 'package:flame/keyboard.dart';
import 'package:flame_audio/flame_audio.dart'; import 'package:flame_audio/flame_audio.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'Bug.dart'; import 'package:firo_runner/bug.dart';
import 'Coin.dart'; import 'package:firo_runner/coin.dart';
import 'Runner.dart'; import 'package:firo_runner/runner.dart';
import 'package:flutter/foundation.dart' show kIsWeb; import 'package:flutter/foundation.dart' show kIsWeb;
const COLOR = const Color(0xFFDDC0A3); const COLOR = Color(0xFFDDC0A3);
const LEVEL2 = 10000000; const LEVEL2 = 10000000;
const LEVEL3 = 20000000; const LEVEL3 = 20000000;
@ -46,7 +46,7 @@ void main() async {
class MyGame extends BaseGame with PanDetector, TapDetector, KeyboardEvents { class MyGame extends BaseGame with PanDetector, TapDetector, KeyboardEvents {
TextPaint textPaint = TextPaint( TextPaint textPaint = TextPaint(
config: TextPaintConfig(fontSize: 48.0), config: const TextPaintConfig(fontSize: 48.0),
); );
late CircuitBackground circuitBackground; late CircuitBackground circuitBackground;
@ -161,7 +161,7 @@ class MyGame extends BaseGame with PanDetector, TapDetector, KeyboardEvents {
} }
runner.sprite.animation!.reset(); runner.sprite.animation!.reset();
shouldReset = false; shouldReset = false;
this.components.clear(); components.clear();
setUp(); setUp();
} }
@ -218,15 +218,14 @@ class MyGame extends BaseGame with PanDetector, TapDetector, KeyboardEvents {
wireHolder.update(dt); wireHolder.update(dt);
bugHolder.update(dt); bugHolder.update(dt);
if (shouldReset) { if (shouldReset) {
print("should reset");
reset(); reset();
} }
} }
@override @override
void onResize(Vector2 size) { void onResize(Vector2 canvasSize) {
super.onResize(size); super.onResize(canvasSize);
blockSize = size.y / 9; blockSize = canvasSize.y / 9;
} }
// Mobile controls // Mobile controls

View File

@ -1,6 +1,6 @@
import 'dart:math'; import 'dart:math';
import 'package:firo_runner/MovingObject.dart'; import 'package:firo_runner/moving_object.dart';
import 'package:firo_runner/main.dart'; import 'package:firo_runner/main.dart';
import 'package:flame/components.dart'; import 'package:flame/components.dart';
@ -70,8 +70,8 @@ class Platform extends MovingObject {
setSize( setSize(
gameRef.blockSize * gameRef.blockSize *
(gameRef.platformHolder.l1!.width / (gameRef.platformHolder.l1.width /
gameRef.platformHolder.l1!.height / gameRef.platformHolder.l1.height /
5), 5),
gameRef.blockSize, gameRef.blockSize,
); );

View File

@ -2,17 +2,18 @@ import 'dart:math';
import 'package:firo_runner/main.dart'; import 'package:firo_runner/main.dart';
import 'package:flame/flame.dart'; import 'package:flame/flame.dart';
import 'Platform.dart'; import 'package:firo_runner/platform.dart';
import 'package:flame/extensions.dart';
class PlatformHolder { class PlatformHolder {
var l1; late Image l1;
var l2; late Image l2;
var m1; late Image m1;
var m2; late Image m2;
var r1; late Image r1;
var r2; late Image r2;
var o1; late Image o1;
var o2; late Image o2;
late List<List<Platform>> platforms = []; late List<List<Platform>> platforms = [];
Random random = Random(); Random random = Random();

View File

@ -1,10 +1,11 @@
import 'package:firo_runner/Bug.dart'; import 'package:firo_runner/bug.dart';
import 'package:firo_runner/Coin.dart'; import 'package:firo_runner/coin.dart';
import 'package:firo_runner/Wire.dart'; import 'package:firo_runner/wire.dart';
import 'package:firo_runner/main.dart'; import 'package:firo_runner/main.dart';
import 'package:flame/effects.dart'; import 'package:flame/effects.dart';
import 'package:flame/extensions.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'Platform.dart'; import 'package:firo_runner/platform.dart';
import 'package:flame/components.dart'; import 'package:flame/components.dart';
@ -16,7 +17,7 @@ enum RunnerState {
float, float,
fall, fall,
die, die,
electro, electrocute,
glitch, glitch,
} }
@ -26,7 +27,7 @@ class Runner extends Component with HasGameRef<MyGame> {
int level = 4; int level = 4;
String previousState = "run"; String previousState = "run";
var runnerPosition = Vector2(0, 0); var runnerPosition = Vector2(0, 0);
var runnerSize; late Vector2 runnerSize;
bool dead = false; bool dead = false;
void setUp() { void setUp() {
@ -72,7 +73,6 @@ class Runner extends Component with HasGameRef<MyGame> {
return; return;
} }
previousState = runnerState; previousState = runnerState;
print(event);
switch (event) { switch (event) {
case "jump": case "jump":
runnerState = event; runnerState = event;
@ -90,7 +90,7 @@ class Runner extends Component with HasGameRef<MyGame> {
}, },
)); ));
break; break;
case "doublejump": case "double_jump":
if (level - 1 < 0) { if (level - 1 < 0) {
break; break;
} }
@ -157,12 +157,12 @@ class Runner extends Component with HasGameRef<MyGame> {
sprite.current = RunnerState.die; sprite.current = RunnerState.die;
gameRef.die(); gameRef.die();
break; break;
case "electro": case "electrocute":
if (dead) { if (dead) {
return; return;
} }
runnerState = event; runnerState = event;
sprite.current = RunnerState.electro; sprite.current = RunnerState.electrocute;
gameRef.die(); gameRef.die();
break; break;
case "glitch": case "glitch":
@ -182,13 +182,12 @@ class Runner extends Component with HasGameRef<MyGame> {
if (gameRef.gameState.isPaused) { if (gameRef.gameState.isPaused) {
return; return;
} }
print(input);
switch (input) { switch (input) {
case "up": case "up":
if (runnerState == "run") { if (runnerState == "run") {
event("jump"); event("jump");
} else if (runnerState == "float" && previousState == "jump") { } else if (runnerState == "float" && previousState == "jump") {
event("doublejump"); event("double_jump");
} else if (runnerState == "duck") { } else if (runnerState == "duck") {
event("run"); event("run");
} }
@ -277,7 +276,6 @@ class Runner extends Component with HasGameRef<MyGame> {
if (coinLevel[i].intersect(runnerRect) != "none") { if (coinLevel[i].intersect(runnerRect) != "none") {
gameRef.gameState.numCoins++; gameRef.gameState.numCoins++;
gameRef.coinHolder.remove(coinLevel, i); gameRef.coinHolder.remove(coinLevel, i);
print(gameRef.gameState.numCoins);
continue; continue;
} }
i++; i++;
@ -287,7 +285,7 @@ class Runner extends Component with HasGameRef<MyGame> {
for (List<Wire> wireLevel in gameRef.wireHolder.wires) { for (List<Wire> wireLevel in gameRef.wireHolder.wires) {
for (int i = 0; i < wireLevel.length; i++) { for (int i = 0; i < wireLevel.length; i++) {
if (wireLevel[i].intersect(runnerRect) != "none") { if (wireLevel[i].intersect(runnerRect) != "none") {
event("electro"); event("electrocute");
return; return;
} }
} }
@ -425,7 +423,7 @@ class Runner extends Component with HasGameRef<MyGame> {
RunnerState.float: floating, RunnerState.float: floating,
RunnerState.fall: falling, RunnerState.fall: falling,
RunnerState.die: dying, RunnerState.die: dying,
RunnerState.electro: dyingElectrocuted, RunnerState.electrocute: dyingElectrocuted,
RunnerState.glitch: dyingGlitch, RunnerState.glitch: dyingGlitch,
}, },
current: RunnerState.run, current: RunnerState.run,

View File

@ -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:firo_runner/main.dart';
import 'package:flame/components.dart'; import 'package:flame/components.dart';

View File

@ -1,13 +1,14 @@
import 'dart:math'; import 'dart:math';
import 'package:firo_runner/Platform.dart'; import 'package:firo_runner/platform.dart';
import 'package:flame/flame.dart'; import 'package:flame/flame.dart';
import 'Wire.dart'; import 'package:firo_runner/wire.dart';
import 'main.dart'; import 'package:firo_runner/main.dart';
import 'package:flame/extensions.dart';
class WireHolder { class WireHolder {
var wire; late Image wire;
Random random = Random(); Random random = Random();
late List<List<Wire>> wires = []; late List<List<Wire>> wires = [];

View File

@ -2,6 +2,8 @@
// Generated file. Do not edit. // Generated file. Do not edit.
// //
// clang-format off
#include "generated_plugin_registrant.h" #include "generated_plugin_registrant.h"

View File

@ -2,6 +2,8 @@
// Generated file. Do not edit. // Generated file. Do not edit.
// //
// clang-format off
#ifndef GENERATED_PLUGIN_REGISTRANT_ #ifndef GENERATED_PLUGIN_REGISTRANT_
#define GENERATED_PLUGIN_REGISTRANT_ #define GENERATED_PLUGIN_REGISTRANT_

View File

@ -7,7 +7,7 @@ packages:
name: async name: async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.6.1" version: "2.8.1"
audioplayers: audioplayers:
dependency: transitive dependency: transitive
description: description:
@ -35,7 +35,7 @@ packages:
name: charcode name: charcode
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.3.1"
clock: clock:
dependency: transitive dependency: transitive
description: description:
@ -104,6 +104,13 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" 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: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
@ -135,6 +142,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.6.3" version: "0.6.3"
lints:
dependency: transitive
description:
name: lints
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
@ -148,7 +162,7 @@ packages:
name: meta name: meta
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0" version: "1.7.0"
ordered_set: ordered_set:
dependency: transitive dependency: transitive
description: description:
@ -279,7 +293,7 @@ packages:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.3.0" version: "0.4.2"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
@ -307,7 +321,7 @@ packages:
name: win32 name: win32
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.2.8" version: "2.2.9"
xdg_directories: xdg_directories:
dependency: transitive dependency: transitive
description: description:

View File

@ -32,6 +32,7 @@ dependencies:
cupertino_icons: ^1.0.2 cupertino_icons: ^1.0.2
dev_dependencies: dev_dependencies:
flutter_lints: ^1.0.4
flutter_test: flutter_test:
sdk: flutter sdk: flutter