initial adjustments to change how camera works
MODIFY
.gitignore
.gitignore
@@ -73,3 +73,5 @@ build/
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
+
+.vscode
\ No newline at end of file

MODIFY
example/pubspec.lock
example/pubspec.lock
@@ -35,7 +35,7 @@ packages:
path: ".."
relative: true
source: path
- version: "0.3.3"
+ version: "0.4.1"
boolean_selector:
dependency: transitive
description:
@@ -57,6 +57,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.3"
+ clock:
+ dependency: transitive
+ description:
+ name: clock
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.0.1"
collection:
dependency: transitive
description:
@@ -78,6 +85,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
+ fake_async:
+ dependency: transitive
+ description:
+ name: fake_async
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.1.0"
flame:
dependency: transitive
description:
@@ -121,13 +135,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
- image:
- dependency: transitive
- description:
- name: image
- url: "https://pub.dartlang.org"
- source: hosted
- version: "2.1.12"
matcher:
dependency: transitive
description:
@@ -155,7 +162,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
- version: "1.6.4"
+ version: "1.7.0"
path_drawing:
dependency: transitive
description:
@@ -212,13 +219,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
- quiver:
- dependency: transitive
- description:
- name: quiver
- url: "https://pub.dartlang.org"
- source: hosted
- version: "2.1.3"
sky_engine:
dependency: transitive
description: flutter

MODIFY
lib/joystick/joystick_controller.dart
lib/joystick/joystick_controller.dart
@@ -61,7 +61,8 @@ abstract class JoystickController extends Component
void update(double t) {}
@override
- int priority() {
- return 25;
- }
+ int priority() => 25;
+
+ @override
+ bool isHud() => true;
}

MODIFY
lib/rpg_game.dart
lib/rpg_game.dart
@@ -11,6 +11,7 @@ import 'package:bonfire/util/game_intercafe/game_interface.dart';
import 'package:bonfire/util/lighting/lighting.dart';
import 'package:bonfire/util/map_explorer.dart';
import 'package:bonfire/util/value_generator.dart';
+import 'package:flame/components/component.dart';
import 'package:flame/keyboard.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@@ -72,6 +73,19 @@ class RPGGame extends BaseGamePointerDetector with KeyboardEvents {
if (gameController != null) gameController.notifyListeners();
}
+ @override
+ void renderComponent(Canvas canvas, Component comp) {
+ if (!comp.loaded()) {
+ return;
+ }
+ canvas.save();
+ if (!comp.isHud()) {
+ canvas.translate(-gameCamera.position.x, -gameCamera.position.y);
+ }
+ comp.render(canvas);
+ canvas.restore();
+ }
+
void addEnemy(Enemy enemy) {
enemies.add(enemy);
add(enemy);

MODIFY
lib/util/background_color_game.dart
lib/util/background_color_game.dart
@@ -5,6 +5,10 @@ import 'package:bonfire/util/game_component.dart';
class BackgroundColorGame extends GameComponent {
final Color color;
BackgroundColorGame(this.color);
+
+ @override
+ bool isHud() => true;
+
@override
void render(Canvas canvas) {
canvas.drawRect(

MODIFY
lib/util/game_intercafe/game_interface.dart
lib/util/game_intercafe/game_interface.dart
@@ -7,6 +7,9 @@ import 'package:flutter/widgets.dart';
class GameInterface extends GameComponent {
List<InterfaceComponent> _components = List();
+ @override
+ bool isHud() => true;
+
@override
bool isTouchable = true;

MODIFY
lib/util/lighting/lighting.dart
lib/util/lighting/lighting.dart
@@ -10,6 +10,9 @@ class Lighting extends GameComponent {
Paint _paintFocus;
Iterable<LightingConfig> _lightToRender = List();
+ @override
+ bool isHud() => true;
+
Lighting({this.color = Colors.transparent}) {
_paintFocus = Paint()
..color = Colors.transparent
@@ -25,6 +28,8 @@ class Lighting extends GameComponent {
canvas.saveLayer(Offset.zero & size, Paint());
canvas.drawColor(color, BlendMode.dstATop);
_lightToRender.forEach((light) {
+ canvas.save();
+ canvas.translate(-gameRef.gameCamera.position.x, -gameRef.gameCamera.position.y);
canvas.drawCircle(
Offset(light.gameComponent.position.center.dx,
light.gameComponent.position.center.dy),
@@ -49,7 +54,9 @@ class Lighting extends GameComponent {
: 1),
paint,
);
+ canvas.restore();
});
+ canvas.restore();
}
static double convertRadiusToSigma(double radius) {

MODIFY
pubspec.lock
pubspec.lock
@@ -50,6 +50,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.3"
+ clock:
+ dependency: transitive
+ description:
+ name: clock
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.0.1"
collection:
dependency: transitive
description:
@@ -71,6 +78,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
+ fake_async:
+ dependency: transitive
+ description:
+ name: fake_async
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.1.0"
flame:
dependency: "direct main"
description:
@@ -114,13 +128,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
- image:
- dependency: transitive
- description:
- name: image
- url: "https://pub.dartlang.org"
- source: hosted
- version: "2.1.12"
matcher:
dependency: transitive
description:
@@ -148,7 +155,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
- version: "1.6.4"
+ version: "1.7.0"
path_drawing:
dependency: transitive
description:
@@ -205,13 +212,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
- quiver:
- dependency: transitive
- description:
- name: quiver
- url: "https://pub.dartlang.org"
- source: hosted
- version: "2.1.3"
sky_engine:
dependency: transitive
description: flutter

initial adjustments to change how camera works