feathers 0.0.2+3 copy "feathers: ^0.0.2+3" to clipboard
feathers: ^0.0.2+3 copied to clipboard

outdated

A lightweight game engine, that keeps your game simple by only using feathers!

Feathers #

A lightweight game engine, that only uses feathers.

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();
  }
}

Feather Loops #

The main loop consists of these 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 #

Coming soon...

5
likes
0
points
45
downloads

Publisher

unverified uploader

Weekly Downloads

A lightweight game engine, that keeps your game simple by only using feathers!

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on feathers