Giter Club home page Giter Club logo

bonfire's Introduction

Powered by Flame Flutter MIT Licence pub package GitHub stars pub points Telegram

bonfire

Bonfire

Build RPG games and similar with the power of FlameEngine!

Bonfire is ideal for building games from the following perspectives:

Test our online DEMO or Download APK.

Documentation

bonfire-engine.github.io

Build for web

Use this command: flutter build web --web-renderer=canvaskit

Useful packages

Name Link
bonfire_bloc pub package
bonfire_spine pub package

Encourage my work

Credits

  • The entire FlameEngine team.
  • And thanks to everyone who contributes and has already contributed.

Contribution

If you find any errors or want to add improvements, you can open a issue or develop the fix and open a pull request. Thank you for your cooperation!

Documentation repository

bonfire's People

Contributors

4mitabh avatar amoshuke avatar dvmatyun avatar emanuel-braz avatar erickzanardo avatar felipequefez avatar fstof avatar jakobodman123 avatar jolexxa avatar jtmcdole avatar kevmoo avatar kylekun avatar lgjenero avatar mel-mouk avatar mrgnhnt96 avatar myconsciousness avatar rafaelbarbosatec avatar rezendegc avatar shinriyo avatar slyklaw avatar spydon avatar taylorho avatar tkshnwesper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bonfire's Issues

Type mismatch in tile_set.dart

tile_set.dart line 55 version = json['version']; throws an exception with json exported from Tiled 1.6. In the exported file, the version is quoted, and therefore a string.

help

Excuse me, what tool was used to make the map file in the sample? Is there a specific version number?

Entering a new scene

Hi, thank you so much for creating this awesome works. I am trying to play around with the darkness_dungeon and the performance is so great. But how do we achieve to jump to another map eg: entering a room/ different level with different scene?

8-Directional Player Animation doesn't work

When a class extends SimplePlayer, there's options for animations for idle and run in four directions (Up, Down, Left, Right), but there's also four Diagonal animations that can be passed (UpLeft, UpRight, DownLeft, DownRight), also for idle and run.

The problem is that the Diagonal Animations doesn't play. The player just go for the four main directions (Up, Down, Left and Right).

Here's an example of an implementation of the 8 directions that doesn't work (but should do):

class ExamplePlayer extends SimplePlayer {
  ExamplePlayer(Vector2 position)
      : super(
          position: position,
          size: Vector2(68, 112),
          animation: SimpleDirectionAnimation(
            idleUp: SpriteSheetIdle.up,
            idleUpLeft: SpriteSheetIdle.upLeft,
            idleUpRight: SpriteSheetIdle.upRight,
            idleDown: SpriteSheetIdle.down,
            idleDownRight: SpriteSheetIdle.downRight,
            idleDownLeft: SpriteSheetIdle.downLeft,
            idleRight: SpriteSheetIdle.right,
            idleLeft: SpriteSheetIdle.left,
            runUp: SpriteSheetRun.up,
            runUpRight: SpriteSheetRun.upRight,
            runUpLeft: SpriteSheetRun.upLeft,
            runDown: SpriteSheetRun.down,
            runDownRight: SpriteSheetRun.downRight,
            runDownLeft: SpriteSheetRun.downLeft,
            runRight: SpriteSheetRun.right,
            runLeft: SpriteSheetRun.left,
          ),
        );
}

It would be awesome if the +4 diagonal directions work properly.

Thanks a lot!!

Build tiled map

I want to know which editor you've used to build the JSON tiled map representation

Tapping anywhere on the screen triggers spriteSelected

Not sure if this is intended functionality, but when I tap anywhere on the screen my interface components are set to their spriteSelected sprite.

Here is my game interface class:

class PlayerInterface extends GameInterface {
  @override
  void resize(Size size) {
    add(InterfaceComponent(
      sprite: Sprite('reset.png'),
      spriteSelected: Sprite('reset_selected.png'),
      height: 40,
      width: 100,
      id: 6,
      position: Position(150, 20),
      onTapComponent: () {
        gameRef.pause();
        showDialog(
          context: gameRef.context,
          builder: (context) {
            return WillPopScope(
              onWillPop: () {
                gameRef.resume();
                return Future.value(true);
              },
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Container(
                    width: 500,
                    height: 200,
                    child: Material(
                      borderRadius: BorderRadius.circular(10),
                      color: Colors.white,
                      child: Text('Wow a dialog!'),
                    ),
                  ),
                ],
              ),
            );
          },
        );
      },
    ));
    super.resize(size);
  }
}

I was able to resolve this issue by extending the InterfaceComponent class and modifying the following method:

  @override
  void onTapDown(int pointer, Offset position) {
    if (spriteSelected != null) spriteToRender = spriteSelected;
    super.onTapDown(pointer, position);
  }

to

  @override
  void onTapDown(int pointer, Offset position) {
    if (this.position.contains(position)) {
      spriteToRender = spriteSelected;
      super.onTapDown(pointer, position);
    }
  }
}

Here's a video of the issue I'm having:
ezgif com-video-to-gif

Take note of the reset button entering the selected state when moving the joystick. Let me know your thoughts; otherwise, plugin has been great so far! 🙌

If this is an issue, I wouldn't mind fixing and creating a PR

flame-1.0.0-releasecandidate.11 update textconfig.dart to text.dart

Hi,

Bonfire is amazing. I am studying how to use it. As flame update to releasecandidate 11, the textconfig.dart and the corresponding class elements are modified and becomes text.dart. No more TextConfig exists.
It broke into TextRenderer, TextPaintConfig, BaseTextConfig, TextPaint etc.

Direction animations fail on Flutter Web build

When building for release and publishing on web, I'm getting console error

LateInitializationError: Field 'runLeft' has not been initialized.

and the enemy is not loading

PR Incoming...

TalkDialog.show() isn't changing character

The TalkDialog.show() needs a saylist array/list as parameter, but when more than one Say() is passed and you change the person property of the Say(), the text changes, but the person not.

Example:

TalkDialog.show(
      context,
      [
        Say(
            text: [
              const TextSpan(
                  text: 'Some Text One'),
            ],
            person: SizedBox(
              child: CharacterOneWidget(),
              height: 100,
              width: 100,
            )),
        Say(
            text: [
              const TextSpan(text: 'Some Text Two'),
            ],
            person: SizedBox(
              child: CharacterTwoWidget(),
              height: 100,
              width: 100,
            ),
            personSayDirection: PersonSayDirection.LEFT),
      ]
    );

In this case, the dialog will be "Some Text One" (first) and then "Some Text Two" (second), it's ok, but the character doesn't change. In booth dialogs, the rendered character will be the "CharacterOneWidget".

Performance on Game Decoration

There is a huge performance problem when you have a considerate amount of GameDecorations on the game... I am currently trying to identify why, but I wasn't able to find the source of problem so far... I tried disabling all collisions, renders, but nothing.... To test this just add around ~5k torches to the example game and the fps should drop to 20 or so...

TiledWorldMap doesn't render transformed tiles

Bonfire silently fails to render any TiledWorldMap tiles which have been rotated or reflected.

You can see in the two screenshots below comparing Tiled's preview, and Bonfire's rendering. There is an inside corner of the top-left room missing. These tiles were rotated, as the tileset only included 2 inner corners. Additionally, the center-top hallway connecting the top-left and top-right rooms is not rendered at all. This hallway was composed of reflected tiles, as the tileset does not include an east-facing doorway, and once I had reflected tiles to build the left half of the hallway, it was easier to just reflect the stamp again to complete the hallway.

Below the screenshots, I have included the data structure from worldmap.json which contains the map itself. Without knowing precisely how it's generated, I'd assume the tiny numbers are tile indexes, and the longer numbers are the tiles which have been transformed, but Bonfire seems to be ignoring them entirely.

Tiled Map Editor Preview:
Expected

Bonfire-rendered map:
Actual

Relevant Map JSON entry:
"data":[3, 4, 5, 6, 7, 8, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 3, 4, 5, 6, 7, 8, 9, 28, 48, 48, 30, 13, 23, 16, 14, 16, 31, 29, 41, 536870954, 536870963, 2684354611, 2684354611, 2684354611, 2684354602, 12, 17, 25, 29, 38, 29, 41, 37, 40, 25, 17, 29, 29, 14, 48, 26, 49, 40, 18, 536870955, 536870928, 2684354607, 2684354599, 2684354576, 2684354603, 2147483666, 25, 25, 29, 26, 17, 50, 46, 38, 24, 26, 40, 22, 30, 14, 53, 17, 40, 27, 536870956, 536870952, 2684354607, 2684354576, 2684354600, 2684354604, 2147483675, 53, 22, 49, 39, 31, 41, 55, 56, 57, 58, 57, 1610612748, 1610612757, 26, 30, 39, 52, 50, 536870957, 536870966, 2684354614, 2684354614, 2684354614, 2684354605, 28, 38, 47, 38, 38, 40, 50, 0, 0, 0, 0, 0, 0, 37, 52, 22, 16, 16, 41, 0, 0, 0, 0, 0, 0, 37, 16, 23, 53, 49, 39, 41, 0, 0, 0, 0, 0, 0, 46, 39, 38, 15, 24, 50, 0, 0, 0, 0, 0, 0, 28, 52, 30, 52, 14, 22, 50, 0, 0, 0, 0, 0, 0, 55, 56, 57, 58, 62, 63, 0, 0, 0, 0, 0, 0, 37, 31, 22, 47, 14, 13, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 31, 53, 25, 47, 31, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 24, 17, 14, 15, 38, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 30, 25, 48, 16, 38, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 25, 53, 13, 39, 26, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 56, 57, 34, 35, 62, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 43, 44, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 39, 16, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 16, 40, 54, 0, 3, 4, 5, 6, 7, 6, 7, 4, 5, 6, 7, 4, 5, 6, 7, 5, 6, 7, 45, 0, 51, 39, 16, 54, 0, 12, 48, 31, 17, 26, 17, 26, 48, 31, 17, 26, 48, 31, 17, 26, 22, 38, 49, 54, 0, 51, 47, 47, 54, 0, 28, 17, 22, 52, 26, 52, 26, 17, 22, 52, 26, 17, 22, 52, 26, 25, 38, 48, 54, 0, 51, 49, 22, 54, 0, 37, 14, 38, 40, 13, 40, 13, 14, 38, 40, 13, 14, 38, 40, 13, 26, 14, 15, 54, 0, 51, 17, 25, 54, 0, 55, 56, 57, 56, 57, 56, 57, 56, 57, 56, 57, 56, 57, 56, 57, 58, 34, 35, 63, 0, 51, 48, 47, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 43, 44, 7, 8, 21, 31, 15, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 13, 38, 14, 13, 13, 25, 25, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 13, 49, 40, 31, 53, 29, 22, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60, 56, 57, 58, 58, 58, 58, 62, 63, 0],

Cannot compile with bonfire, seems linked to flame 1.0.0

Greetings,

I cannot compile your awesome api :/

Here is my output when I build :

Performing hot restart...
Syncing files to device SM G950U1...
../../.pub-cache/hosted/pub.dartlang.org/bonfire-1.6.0/lib/base/bonfire_game.dart:26:8: Error: Error when reading '../../.pub-cache/hosted/pub.dartlang.org/flame-1.0.0-releasecandidate.14/lib/keyboard.dart': No such file or directory
import 'package:flame/keyboard.dart';
       ^
../../.pub-cache/hosted/pub.dartlang.org/bonfire-1.6.0/lib/base/bonfire_game.dart:31:47: Error: Type 'KeyboardEvents' not found.
class BonfireGame extends CustomBaseGame with KeyboardEvents {
                                              ^^^^^^^^^^^^^^
../../.pub-cache/hosted/pub.dartlang.org/bonfire-1.6.0/lib/base/bonfire_game.dart:31:7: Error: The type 'KeyboardEvents' can't be mixed in.
class BonfireGame extends CustomBaseGame with KeyboardEvents {
      ^
../../.pub-cache/hosted/pub.dartlang.org/bonfire-1.6.0/lib/base/game_component.dart:71:8: Error: The method 'GameComponent.remove' has fewer positional arguments than those of overridden method 'Component.remove'.
  void remove() {
       ^
../../.pub-cache/hosted/pub.dartlang.org/flame-1.0.0-releasecandidate.14/lib/src/components/component.dart:238:8: Context: This is the overridden method ('remove').
  void remove(Component c) {
       ^
../../.pub-cache/hosted/pub.dartlang.org/bonfire-1.6.0/lib/game_interface/game_interface.dart:57:39: Error: The parameter 'component' of the method 'GameInterface.add' has type 'InterfaceComponent', which does not match the corresponding type, 'Component', in the overridden method, 'Component.add'.
 - 'InterfaceComponent' is from 'package:bonfire/game_interface/interface_component.dart' ('../../.pub-cache/hosted/pub.dartlang.org/bonfire-1.6.0/lib/game_interface/interface_component.dart').
 - 'Component' is from 'package:flame/src/components/component.dart' ('../../.pub-cache/hosted/pub.dartlang.org/flame-1.0.0-releasecandidate.14/lib/src/components/component.dart').
Change to a supertype of 'Component', or, for a covariant parameter, a subtype.
  Future<void> add(InterfaceComponent component) async {
                                      ^
../../.pub-cache/hosted/pub.dartlang.org/flame-1.0.0-releasecandidate.14/lib/src/components/component.dart:217:16: Context: This is the overridden method ('add').
  Future<void> add(Component component) {
               ^
../../.pub-cache/hosted/pub.dartlang.org/bonfire-1.6.0/lib/map/map_game.dart:16:14: Error: The return type of the method 'MapGame.children' is 'List<Tile>', which does not match the return type, 'ComponentSet', of the overridden method, 'Component.children'.
 - 'List' is from 'dart:core'.
 - 'Tile' is from 'package:bonfire/map/tile/tile.dart' ('../../.pub-cache/hosted/pub.dartlang.org/bonfire-1.6.0/lib/map/tile/tile.dart').
 - 'ComponentSet' is from 'package:flame/src/components/component_set.dart' ('../../.pub-cache/hosted/pub.dartlang.org/flame-1.0.0-releasecandidate.14/lib/src/components/component_set.dart').
Change to a subtype of 'ComponentSet'.
  List<Tile> children = [];
             ^
../../.pub-cache/hosted/pub.dartlang.org/flame-1.0.0-releasecandidate.14/lib/src/components/component.dart:47:27: Context: This is the overridden method ('children').
  late final ComponentSet children = createComponentSet();
                          ^
../../.pub-cache/hosted/pub.dartlang.org/bonfire-1.6.0/lib/util/text_damage_component.dart:70:13: Error: Too few positional arguments: 1 required, 0 given.
      remove();
            ^
../../.pub-cache/hosted/pub.dartlang.org/bonfire-1.6.0/lib/util/text_damage_component.dart:73:13: Error: Too few positional arguments: 1 required, 0 given.
      remove();
            ^
../../.pub-cache/hosted/pub.dartlang.org/bonfire-1.6.0/lib/util/value_generator_component.dart:53:11: Error: Too few positional arguments: 1 required, 0 given.
    remove();
          ^
../../.pub-cache/hosted/pub.dartlang.org/bonfire-1.6.0/lib/base/custom_base_game.dart:211:11: Error: Superclass has no method named 'onResize'.
    super.onResize(size);
          ^^^^^^^^
../../.pub-cache/hosted/pub.dartlang.org/bonfire-1.6.0/lib/util/bonfire_game_ref.dart:19:17: Error: 'BaseComponent' isn't a type.
    if (this is BaseComponent) {
                ^^^^^^^^^^^^^
../../.pub-cache/hosted/pub.dartlang.org/bonfire-1.6.0/lib/util/bonfire_game_ref.dart:20:16: Error: 'BaseComponent' isn't a type.
      (this as BaseComponent)
               ^^^^^^^^^^^^^
../../.pub-cache/hosted/pub.dartlang.org/flame-1.0.0-releasecandidate.14/lib/src/device.dart:16:25: Error: Method not found: 'SystemChrome.setEnabledSystemUIMode'.
    return SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
                        ^^^^^^^^^^^^^^^^^^^^^^
../../.pub-cache/hosted/pub.dartlang.org/bonfire-1.6.0/lib/base/custom_base_game.dart:18:16: Error: The superclass, 'Game', has no unnamed constructor that takes no arguments.
abstract class CustomBaseGame extends Game with FPSCounter, PointerDetector {
               ^
Restarted application in 2,270ms.

Here is my pubspec.yaml file dependencies :

dependencies:
  flutter:
    sdk: flutter
  bonfire: ^1.6.0

I checked the "missing keyboard.dart file", and I dont have it :

➜  bonfire_test ls ../../.pub-cache/hosted/pub.dartlang.org/flame-1.0.0-releasecandidate.14/lib/
assets.dart            effects.dart           flame.dart             geometry.dart          input.dart             palette.dart           particles.dart         src                    widgets.dart
components.dart        extensions.dart        game.dart              image_composition.dart layers.dart            parallax.dart          sprite.dart            timer.dart

Tap movement instead of joystick?

Would it be possible to add tap handling to move the player (or to carry game actions) instead of the virtual joystick? This would help for games such as adventure games where the user might want to simply tap on various locations on screen instead of guiding the player via joystick.

Didn’t support tileset of the type of ‘Collection Of Images’

I create a map that using a tileset of the type of ‘Collection Of Images’, and I found that this kind of tileset isn’t support. For now it only support tileset of the type ‘Based on Tileset Image’, so I
tried merge the collection of images into one image, but I found that the size of the image is much bigger than
the total size of the collection of images. So tileset of the type ‘Collection Of Image’ is necessary for some case.

tileset example

{ "columns":0,
 "grid":
    {
     "height":1,
     "orientation":"orthogonal",
     "width":1
    },
 "margin":0,
 "name":"test5",
 "spacing":0,
 "tilecount":4,
 "tiledversion":"1.4.3",
 "tileheight":512,
 "tiles":[
        {
         "id":0,
         "image":"..\/..\/Angle\/barrel_E.png",
         "imageheight":512,
         "imagewidth":256,
         "objectgroup":
            {
             "draworder":"index",
             "id":2,
             "name":"",
             "objects":[
                    {
                     "height":46,
                     "id":1,
                     "name":"",
                     "rotation":0,
                     "type":"",
                     "visible":true,
                     "width":89,
                     "x":82,
                     "y":400
                    }, 
                    {
                     "height":16,
                     "id":2,
                     "name":"",
                     "rotation":0,
                     "type":"",
                     "visible":true,
                     "width":24,
                     "x":79,
                     "y":377
                    }],
             "opacity":1,
             "type":"objectgroup",
             "visible":true,
             "x":0,
             "y":0
            }
        }, 
        {
         "id":1,
         "image":"..\/..\/Angle\/barrel_N.png",
         "imageheight":512,
         "imagewidth":256,
         "objectgroup":
            {
             "draworder":"index",
             "id":2,
             "name":"",
             "objects":[
                    {
                     "height":36,
                     "id":1,
                     "name":"",
                     "rotation":0,
                     "type":"",
                     "visible":true,
                     "width":83,
                     "x":85,
                     "y":409
                    }],
             "opacity":1,
             "type":"objectgroup",
             "visible":true,
             "x":0,
             "y":0
            }
        }, 
        {
         "id":3,
         "image":"..\/..\/Angle\/barrel_W.png",
         "imageheight":512,
         "imagewidth":256
        }],
 "tilewidth":256,
 "type":"tileset",
 "version":1.4
}

Allow to use Bonfire classes without need to wrap with BonfireWidget

I'm building a game but is not an RPG and your widgets could be very helpful, could you please see if it's possible to allow to use your classes (Joystick, Interface, Lighting, Enemy and Camera) without need to wrap the app inside BonfireWidget, so I can just render as Components and custom their actions?

For example, If I try to render a Joystick I get size = null, since I didn't use BonfireWidget, but if I use it I don't have a map since it's not an RPG game and the parameter map is required.

import 'dart:ui';
import 'package:bonfire/bonfire.dart';
import 'package:flame/components/component.dart';

class CustomJoystick extends Component {

  Joystick joystick;

  CustomJoystick(){

    joystick = Joystick(
      actions: [



      ]
    );

  }

  @override
  void render(Canvas c) {
    joystick.render(c);

  }

  @override
  void update(double dt) {
    joystick.update(dt);
  }

  
}
class AlienGame extends BaseGame with PanDetector, HasGameRef {

  AlienGame(Size screenSize){

    this.size = screenSize;

    add(Background());

    add(PlayerComponent());

    add(CustomJoystick());
 The following NoSuchMethodError was thrown during a scheduler callback:
I/flutter (32538): The getter 'size' was called on null.
I/flutter (32538): Receiver: null
I/flutter (32538): Tried calling: size
I/flutter (32538): When the exception was thrown, this was the stack:
I/flutter (32538): #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
I/flutter (32538): #1      Joystick.update (package:bonfire/joystick/joystick.dart:44:17)
I/flutter (32538): #2      CustomJoystick.update (package:aliengame/src/components/joystick.dart:30:14)

I want to achieve X-direction flip animation

I want to achieve X-direction flip animation, this writing seems not to work, thank you for your guidance
`
void render(Canvas canvas) {

if (position == null) return;

//renderFlipX
if (renderFlipX) {
  print("renderFlipX:" + position!.width.toString() + "," + position!.height.toString());
  canvas.translate(position!.width / 2, position!.height / 2);
  canvas.scale(-1.0,1.0);
  canvas.translate(-position!.width / 2, -position!.height / 2);
}

if (_fastAnimation != null) {
  _fastAnimation?.render(canvas);
} else {
  current?.getSprite().renderFromVector2Rect(canvas, position!);
}

}`

Compile error after using bonfire into a newly created project.

Hi,

Hope you are doing well and thank you for creating this awesome plugin.

I am able to compile and run the example project in this repo. And I can add bonfire into my pubspec.yaml. However, I can't compile the app after I trying to use the package in a dart file in a new project.

Please help me, and let me know if you need more information for the issue.

Thanks!

My Flutter version:
Screenshot 2021-07-12 at 5 40 18 PM

Errors:
Screenshot 2021-07-12 at 5 12 24 PM

Null reference after .updateTiles() when using images not used before.

How to reproduce. I was trying to load a new level.

  • Use BonfireWidget(..) to load some tiles, like in the Manual example.
  • do gameRef.map.updateTiles(newTiles)

When loading the tiles with updateTiles if the image asset has been used before it will be ok but if the image has not been used before it will crash. Currently I am working around this by loading some 1x1 tiles off screen to pre-load the images.

Thanks very much for your hard work. I am loving the engine so far.


In browser:
Error: Unexpected null value.
at Object.throw_ [as throw] (http://localhost:53302/dart_sdk.js:5067:11)
at Object.nullCheck (http://localhost:53302/dart_sdk.js:5394:30)
at Function.getSprite (http://localhost:53302/packages/bonfire/widgets/bonfire_widget.dart.lib.js:9583:57)
at tile_model.TileModelSprite.new.getSprite (http://localhost:53302/packages/bonfire/widgets/bonfire_widget.dart.lib.js:10436:50)
at tile_model.TileModel.new.getTile (http://localhost:53302/packages/bonfire/widgets/bonfire_widget.dart.lib.js:10676:85)
at MappedListIterable.new. (http://localhost:53302/packages/bonfire/widgets/bonfire_widget.dart.lib.js:6981:62)
at MappedListIterable.new.elementAt (http://localhost:53302/dart_sdk.js:24312:25)
at ListIterator.new.moveNext (http://localhost:53302/dart_sdk.js:24101:55)
at JsIterator.next (http://localhost:53302/dart_sdk.js:6873:21)
at Function.of (http://localhost:53302/dart_sdk.js:46768:18)
at MappedListIterable.new.toList (http://localhost:53302/dart_sdk.js:23908:30)
at map_world.MapWorld.new.[_buildTiles] (http://localhost:53302/packages/bonfire/widgets/bonfire_widget.dart.lib.js:6981:118)
at map_world.MapWorld.new.[_searchTilesToRender] (http://localhost:53302/packages/bonfire/widgets/bonfire_widget.dart.lib.js:6868:56)
at Object._microtaskLoop (http://localhost:53302/dart_sdk.js:40708:13)
at _startMicrotaskLoop (http://localhost:53302/dart_sdk.js:40714:13)
at http://localhost:53302/dart_sdk.js:36191:9

on Android:
E/flutter (16284): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Null check operator used on a null value
E/flutter (16284): #0 MapAssetsManager.getSprite (package:bonfire/map/map_assets_manager.dart:27:63)
E/flutter (16284): #1 TileModelSprite.getSprite (package:bonfire/map/tile/tile_model.dart:26:29)
E/flutter (16284): #2 TileModel.getTile (package:bonfire/map/tile/tile_model.dart:173:27)
E/flutter (16284): #3 MapWorld._buildTiles. (package:bonfire/map/map_world.dart:222:16)
E/flutter (16284): #4 MappedListIterable.elementAt (dart:_internal/iterable.dart:413:31)
E/flutter (16284): #5 ListIterator.moveNext (dart:_internal/iterable.dart:342:26)
E/flutter (16284): #6 new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:206:27)
E/flutter (16284): #7 new _GrowableList.of (dart:core-patch/growable_array.dart:153:28)
E/flutter (16284): #8 new List.of (dart:core-patch/array_patch.dart:51:28)
E/flutter (16284): #9 ListIterable.toList (dart:_internal/iterable.dart:213:44)
E/flutter (16284): #10 MapWorld._buildTiles (package:bonfire/map/map_world.dart:223:8)
E/flutter (16284): #11 MapWorld._searchTilesToRender (package:bonfire/map/map_world.dart:83:26)
E/flutter (16284): #12 _rootRun (dart:async/zone.dart:1418:47)
E/flutter (16284): #13 _CustomZone.run (dart:async/zone.dart:1328:19)
E/flutter (16284): #14 _CustomZone.runGuarded (dart:async/zone.dart:1236:7)
E/flutter (16284): #15 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1276:23)
E/flutter (16284): #16 _rootRun (dart:async/zone.dart:1426:13)
E/flutter (16284): #17 _CustomZone.run (dart:async/zone.dart:1328:19)
E/flutter (16284): #18 _CustomZone.runGuarded (dart:async/zone.dart:1236:7)
E/flutter (16284): #19 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1276:23)
E/flutter (16284): #20 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
E/flutter (16284): #21 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
E/flutter (16284):

Desktop Support

It looks like Bonfire doesn't support desktop platforms currently (at least Windows?)
I managed to get darkness dungeon to build, but it spams renderbox size errors. Was just wondering if this is a known issue before I start digging in further?

Tiled: using polygon from object layer to create transparent collision object

Hello and thank you for your great work. It is really nice and powerful to work with bonfire.
Is it possible to create a polygon in Tiled (object layer) and to define it as a collision object with bonfire ?
For example, on a beach, create a polygone around the sea, to force player to stay on the beach.
Thanks !

White space when setPotrait

hello, great work i love this

but i have some problem, don't know it's bug or something wrong, so when set layout to potrait there have space with white color, in main i have set black, but just comeback to horizontal the no more white spare

Screen Shot 2020-04-08 at 18 26 31

Screen Shot 2020-04-08 at 18 27 06

click joystick, return directional MOVE_RIGHT

In darkness_dungeon, When I click in the joystick area, function joystickChangeDirectional always return JoystickMoveDirectional.MOVE_RIGHT, even if event.intensity is 0.
eg: The knight walked to the left and stopped, When I click in the joystick area immediately turned to the right.

Random Game Crash

Hello! First of all, i'm loving your work!
I'm creating a simple game for android and i'm using your game engine. Recently i've updated the Bonfire version to bonfire: ^2.2.3 and now i'm getting some random crashes while playing. This only started happening after i updated my version.

i throws the following error : Bad state: Cannot find reference BonfireGameInterface in the component tree.

I'm using the BonfireTiledWidget to create the game. Can you point me in some direction, im kind of lost here trying to resolve it.

Thank you for your time!

GameDecoration frontFromPlayer=true does not render on top of Player Object

I try to create a decoration object by bonfire: ^0.6.18, I set frontFromPlayer:true as expected it to be rendered on top of Player object but the decoration still render below Player Object.

Testing on Web and Android emulator, both are got the same result.

Jerry(this.initPosition)
: super.sprite(
Sprite(
"itens/jerry.png",
),
width: 192,
height: 67,
initPosition: initPosition,
frontFromPlayer: true) {
_textConfig = TextConfig(
color: Colors.white,
fontSize: 10,
);
}

Support multiple tilesets in the same map?

Bonfire is a great project, but it seems that bonfire doesn't support multiple tilesets in the same map now.
I test with 0.6.15, and the map struct like this:

{ 
 "compressionlevel":-1,
 "height":20,
 "infinite":false,
 "layers":[
     ...
 ],
 "nextlayerid":3,
 "nextobjectid":1,
 "orientation":"orthogonal",
 "renderorder":"right-down",
 "tiledversion":"2020.06.25",
 "tileheight":16,
 "tilesets":[
        {
         "firstgid":1,
         "source":"world_set.json"
        }, 
        {
         "firstgid":2,
         "source":"outside_set.json"
 }],
 "tilewidth":16,
 "type":"map",
 "version":1.4,
 "width":20
}

Flutter Web does not support the blend mode: BlendMode.clear

Running example with Flutter web got the following error:

══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
The following UnimplementedError was thrown during a scheduler callback:
Flutter Web does not support the blend mode: BlendMode.clear

When the exception was thrown, this was the stack:
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 212:49  throw_
lib/_engine/engine/bitmap_canvas.dart 884:7                                   _stringForBlendMode
lib/_engine/engine/canvas_pool.dart 704:11                                    set blendMode
lib/_engine/engine/canvas_pool.dart 772:5                                     setUpPaint
lib/_engine/engine/bitmap_canvas.dart 212:31                                  [_setUpPaint]
lib/_engine/engine/bitmap_canvas.dart 337:5                                   drawCircle
lib/_engine/engine/surface/recording_canvas.dart 1179:11                      apply
lib/_engine/engine/surface/recording_canvas.dart 164:24                       apply
lib/_engine/engine/surface/picture.dart 272:19                                paintCallback
lib/_engine/engine/surface/surface.dart 48:14                                 commitScene
lib/_engine/engine/surface/scene_builder.dart 547:7                           <fn>
lib/_engine/engine/profiler.dart 36:18                                        timeAction
lib/_engine/engine/surface/scene_builder.dart 541:12                          build
packages/flutter/src/rendering/layer.dart 777:35                              buildScene
packages/flutter/src/rendering/view.dart 243:36                               compositeFrame
packages/flutter/src/rendering/binding.dart 407:18                            drawFrame
packages/flutter/src/widgets/binding.dart 914:13                              drawFrame
packages/flutter/src/rendering/binding.dart 286:5                             [_handlePersistentFrameCallback]
packages/flutter/src/scheduler/binding.dart 1116:15                           [_invokeFrameCallback]
packages/flutter/src/scheduler/binding.dart 1055:9                            handleDrawFrame
packages/flutter/src/scheduler/binding.dart 971:5                             [_handleDrawFrame]
lib/_engine/engine/window.dart 761:13                                         _invoke
lib/_engine/engine/window.dart 361:5                                          invokeOnDrawFrame
lib/_engine/engine.dart 227:18                                                <fn>
════════════════════════════════════════════════════════════════════════════════════════════════════
Another exception was thrown: PersistedScene: is in an unexpected state.

Looks like it comes from https://github.com/RafaelBarbosatec/bonfire/blob/master/lib/lighting/lighting_component.dart#L18.

Flutter Web does not support the blend mode: BlendMode.clear

I have got this error when trying to run on web.The first screen shown up but after click on Manual Map or Tiled Map then the error "Flutter Web does not support the blend mode: BlendMode.clear" display in flutter console. and following by non stop throwing "PersistedScene: is in an unexpected state." error message.

NPC

Thank you! Bonfire is a great help for anyone writing RPGs.

I see that you have players and enemies as part of the engine. Is there a plan to add NPCs a well?
NPCs are central to interaction in RPG style games.

If now what is the recommended way of modelling NPCs.

Can't show a dialog on TalkDialog finish method

Hey!

I'm trying to show a dialog on the finish method of TalkDialog after making contact with an object, but this causes the last Say to keep on screen forever and the dialog is not shown.

@override
  void onContact(GameComponent component) {
    if (component is Player && !alreadyTalked) {
      alreadyTalked = true;
      TalkDialog.show(
        gameRef.context,
        [
          Say('a'),
          Say('b'),
          Say('c'),
        ],
        finish: () => _showMyDialog(),
      );
    }
  }

  void _showMyDialog() {
    print('working'); // This is sucessfully printed on the console, so the method is being called without problems
    showDialog(
      context: gameRef.context,
      builder: (context) => AlertDialog(
        title: Text(
          "This is a dialog",
        ),
      ),
    );
}

There are no errors on the console.

I can get it to work if I set a variable in this finish method from the Player class, which is listened on update(), but I don't know if this is the best approach since I will have lots of scenarios like this and would have to listen to many things on the Player update().

Any ideas what to do in this scenario? Thanks!

JoystickMoveToPosition not working as expected

Hello,

I'm trying to use JoystickMoveToPosition on my map built with tiled where my objects have polygon collision, but the a_star algorithm seems to not detect them, resulting in locking the player as shown in the video:

Screen_Recording_20210606-183952.mp4

New tile 1.5 version update. FPS issue

  1. It throws an exception when I added new map.json via new version of Tile1.5. I just manually changed Tile version in json to 1.3.5 and it worked.
  2. I created a bigger map which causes to low fps. I guess it renders all map. I suggest to add logic which renders only visible objects in viewport. Is it implemented in dynamic rendering branch? I haven’t looked code of that branch yet

After I upgrade to bonfire version 1.0.3, it cant play upRight animation.

After I upgrade to bonfire version 1.0.3, it cant play upRight animation.
When I drag the joystick_nob to upRight direction,
it call three move methods one by one, first moveUpRight, then moveRight, finally moveUp.
And finally it play the up animation.
In other words, the upRight animation has not been played, but the up animation is playing.

right way to display particles?

hello I'm trying to show particles but I can't see them, I'm using the darkness_dungeon demo in the Knight class
I added the method

@OverRide
void update(double dt) {
super.update(dt);

 // Adds thruster particles.
 final particleComponent = ParticleComponent(
   Particle.generate(
     count: 10,
     life span: 1,
     generator: (i) => AcceleratedParticle(
       acceleration: Vector2(130.8183135986328, 311.3004455566406),
       speed: Vector2(100, 100),
       position: Vector2(130.8183135986328, 311.3004455566406),
       child: CircleParticle(
         radius: 1,
         paint: Paint()..color = Colors.red,
       ),
     ),
   ),
 );

 gameRef.add(particleComponent);

}
are drawn below the map

particulas abajo de tiled

Add polygon collision detection

First, sorry for my poor English.
How about add polygon collision detection?
Polygon collision detection is useful in many cases, although it is more complicated than the Rectangle collision detection.
To reduce the computing, each polygon stores its outsideBox rectangle((minX, minY),(maxX, maxY)).
Detect the outsideBox first, if there is no collision, return false. If there is a collision, continue to have the rectangleToPolygon detection or polygonToPolygon detection.
Here is a reference package collision_check. May it could do some help.

State managers

Hello . Is it possible to add a state manager like flame_bloc , or your cubes with similar capabilities ?

How to add more complex dependencies to the game?

Or how to use your listeners?

Tiled Map sometimes does not render some tiles

Hi @RafaelBarbosatec !

I'm testing some things and found this problem (reproduced on Web & Windows in debug and release modes, the issue still happens, did not test on Android but it is very likely that it happens as well), I'm using the latest version and this doesn't show any error logs:

black_squares.mp4

OBS: Delay is from my screenrecorder, there is no delay in the game, just the black squares issue.
The map is 39x36 (tile size is 16 pixels), only common tiles without collisions.

error trying to use Tiled map with margin/spacing

Map is not correctly displayed when the Tileset file has margin/spacing defined. When I open map file or tileset on Tiled, everything works as expected, but running the game loads tiles incorrectly without using spacing between. Tileset class already obtains spacing and margin param from JSON file, but I think is not been used. Actually, I didn't find any method using these values. Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.