feathers 0.0.4

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 55

Feathers

A lightweight game engine, that only uses feathers.

Why Feathers?

The idea of feathers is to give you full control over your app. By allowing you to create the components you want, for the feathers you design. All you need to know, is a feather!

Quick Start

lib/main.dart

import 'package:feathers/feathers.dart';
import 'dart:ui'

void main() async {
  FeatherEngine engine = new FeatherEngine();
  engine.initialize(new MyGame());
}

class MyGame extends Feather {
  @override
  void init() {
    this.addFeather('usersprite', new User());
    super.init();
  }
}

class User extends Feather {
  @override
  void init() {
    this.setQuill<SpriteQuill>(new SpriteQuill())
      ..setSize(50.0, 150.0)
      ..setPosition(25.0, 50.0)
      ..initWithColor(0xFFFF0000);
    super.init();
  }
}

The Feather Loop

Each feather, and all associated components follow a main way of looping. Primarily through the input, update, and render methods.

init: Initializes the feather/component.

destroy: Disposes of the feather/component, and all internal properties.

load: Loads any data neccessary for the feather/component.

unload: Unloads any data, to make room for loading new data.

input: Handles input events as neccessary for the feather/component.

update: Updates our feather/component.

render: Draws our feather/component to the screen.

Custom Components & Quills

Creating custom components is simple. Create a new file to hold your components, perhaps storing them in a custom_components directory. Add your class extending the Component class, then implement the methods appropriatly (found above in the Feather Loops section. It is up to you to determine how you want your component to handle everything! See example below:

class CustomComponent extends Component {
  @override
  void init() {
  }

  @override
  void destroy() {
  }

  @override
  void load() {
  }

  @override
  void input(Event event) {
  }

  @override
  void update(Time time) {
  }

  @override
  void render(Context context) {
  }
}

Quills

Create quills is similar to creating components, except you do not need to implement the core loop functionality, since this is already handled for you. The main focus of your custom quill is to add whichever components you wish to have combined into one component set. See example below:

class ColoredSquareQuill extends Quill {
  void initWithColor(Color color) {
    addComponent<PositionComponent>(new PositionComponent())
      ..setPosition(25.0, 50.0);

    addComponent<SizeComponent>(new SizeComponent())
      ..setSize(75.0, 75.0);

    addComponent<ColorComponent>(new ColorComponent())
      ..setColor(color);
  }
}

NOTE: Quill overrides require calling the super method at the end

Creating Consistent Components and Quills

  • Components should not contain constructors, to keep things simple. This will help keep your code maintainable. Future versions plan to remove adding access to constructors.
  • Quills should init with a unique method, such as initWithColor, rather than using the init override. Again, this helps keep code more maintainable.

Contributing

I hope that one day there will be a community of components and quills to help new users streamline their app development.

More Coming soon...

[0.0.1] - TODO: Add release date.

  • TODO: Describe initial release.

example/lib/main.dart

import 'package:feathers/feathers.dart';

import 'dart:ui';
import 'dart:math';

void main() async {
  FeatherEngine engine = new FeatherEngine();
  engine.initialize(new MyGame());
}

class MyGame extends Feather {
  Timer timer;

  /// For most things, we can handle everything inside of the init function
  /// ...but if you need to do something very specific during any other cycle
  /// ...such as load/unload/input/update/render, you have access to override
  /// ...those as well

  @override
  void init() {
    /// Add our scenes as part of `MyGame`
    addFeather('splash_scene', new SplashScene());
    addFeather('my_scene', new MyScene());

    /// Add a `ManagerComponent` to `MyGame`
    addComponent<ManagerComponent>(new ManagerComponent())
      ..setCurrent('splash_scene');

    /// Setup a timer for showing the 'splash_scene', then change to
    /// the 'my_scene' scene after 3 seconds.
    timer = new Timer(3.0);

    /// Always call `super` at the end of any override
    super.init();
  }

  @override
  void update(Time time) {
    if (timer != null && timer.completed(time)) {
      getComponent<ManagerComponent>().setCurrent('my_scene');
      timer = null;
    }

    super.update(time);
  }
}

class SplashScene extends Feather {
  @override
  void init() {
    /// This demonstrates using a feather without a preset `Quill`
    /// alternatively we could use the `SpriteQuill` to define our splash_image
    Feather splashImage = createFeather('splash_image');
    splashImage.addComponent<SizeComponent>(new SizeComponent())
      ..setSize(150.0, 150.0);
    splashImage.addComponent<PositionComponent>(new PositionComponent())
      ..setPosition(100.0, 225.0);
    splashImage.addComponent<TextureComponent>(new TextureComponent())
      ..setTexture(new Texture('splash.png'))
      ..setSource(Rect.fromLTWH(0.0, 0.0, 350.0, 351.0));

    super.init();
  }
}

class MyScene extends Feather {
  int direction = 0;
  @override
  void init() {
    /// Give this scene a rectangle size from (0.0, 0.0) to (380.0, 700.0)
    addComponent<PositionComponent>(new PositionComponent())
      ..setPosition(0.0, 0.0);
    addComponent<SizeComponent>(new SizeComponent())
      ..setSize(Context.screen.width, Context.screen.height);

    InputComponent input =
        this.addComponent<InputComponent>(new InputComponent());
    input.addEvent(new Event(EventType.TOUCHDOWN), () {
      direction = Random().nextInt(3);
    });

    this.createFeather('user').setQuill<SpriteQuill>(new SpriteQuill())
      ..setSize(50.0, 50.0)
      ..setPosition(25.0, 25.0)
      ..initWithColor(const Color(0xFFFFFFFF));

    super.init();
  }

  @override
  void update(Time time) {
    PositionComponent position =
        getFeather('user').getComponent<PositionComponent>();
    double move = 20 * time.elapsedSeconds();
    switch (direction) {
      case 0:
        position.x += move;
        break;
      case 1:
        position.x -= move;
        break;
      case 2:
        position.y += move;
        break;
      case 3:
        position.y -= move;
        break;
    }

    if (position.x > 380) {
      position.x = -50.0;
    } else if (position.x < -50) {
      position.x = 380.0;
    }

    if (position.y > 700) {
      position.y = -50.0;
    } else if (position.y < -50) {
      position.y = 700.0;
    }
    getFeather('user')
        .getQuill<SpriteQuill>()
        .setPosition(position.x, position.y);

    super.update(time);
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  feathers: ^0.0.4

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:feathers/feathers.dart';
  
Version Uploaded Documentation Archive
0.0.4 Aug 10, 2018 Go to the documentation of feathers 0.0.4 Download feathers 0.0.4 archive
0.0.3 Aug 10, 2018 Go to the documentation of feathers 0.0.3 Download feathers 0.0.3 archive
0.0.2+3 Aug 7, 2018 Go to the documentation of feathers 0.0.2+3 Download feathers 0.0.2+3 archive
0.0.2+2 Aug 7, 2018 Go to the documentation of feathers 0.0.2+2 Download feathers 0.0.2+2 archive
0.0.2+1 Aug 4, 2018 Go to the documentation of feathers 0.0.2+1 Download feathers 0.0.2+1 archive
0.0.2 Aug 4, 2018 Go to the documentation of feathers 0.0.2 Download feathers 0.0.2 archive
0.0.1 Aug 2, 2018 Go to the documentation of feathers 0.0.1 Download feathers 0.0.1 archive
0.0.2-dev.1 Aug 4, 2018 Go to the documentation of feathers 0.0.2-dev.1 Download feathers 0.0.2-dev.1 archive
0.0.2-beta.1 Aug 4, 2018 Go to the documentation of feathers 0.0.2-beta.1 Download feathers 0.0.2-beta.1 archive
0.0.1-beta.7 Aug 2, 2018 Go to the documentation of feathers 0.0.1-beta.7 Download feathers 0.0.1-beta.7 archive

All 17 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
14
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
55
Learn more about scoring.

We analyzed this package on Oct 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.4
  • Flutter: 0.9.5

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/core/animation.dart. (-0.50 points)

Analysis of lib/core/animation.dart reported 1 hint:

line 37 col 11: The value of the local variable 'verticalFrames' isn't used.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While there is nothing inherently wrong with versions of 0.0.*, it usually means that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test