fledge_input 0.1.1 copy "fledge_input: ^0.1.1" to clipboard
fledge_input: ^0.1.1 copied to clipboard

Input handling plugin for the Fledge ECS game framework. Provides action-based input mapping with keyboard, mouse, and gamepad support.

example/example.dart

// ignore_for_file: avoid_print
import 'package:flutter/services.dart';
import 'package:fledge_ecs/fledge_ecs.dart';
import 'package:fledge_input/fledge_input.dart';

// Define your game actions
enum GameActions { move, jump, attack }

void main() async {
  // Create an input map with bindings
  final inputMap = InputMap.builder()
      // Keyboard
      .bindWasd(ActionId.fromEnum(GameActions.move))
      .bindKey(LogicalKeyboardKey.space, ActionId.fromEnum(GameActions.jump))
      // Gamepad
      .bindLeftStick(ActionId.fromEnum(GameActions.move))
      .bindGamepadButton('a', ActionId.fromEnum(GameActions.jump))
      .build();

  // Create the input plugin
  final inputPlugin = InputPlugin.simple(
    context: InputContext(name: 'gameplay', map: inputMap),
  );

  // Add to your app
  final app = App()
    ..addPlugin(TimePlugin())
    ..addPlugin(inputPlugin);

  // In a system, read input like this:
  // final actions = world.getResource<ActionState>()!;
  //
  // if (actions.justPressed(ActionId.fromEnum(GameActions.jump))) {
  //   print('Jump!');
  // }
  //
  // final move = actions.vector2Value(ActionId.fromEnum(GameActions.move));
  // print('Move: (${move.$1}, ${move.$2})');

  print('Input plugin configured with ${inputMap.bindings.length} bindings');
  print('Wrap your game widget with InputWidget to capture input');

  // Note: In Flutter, wrap your game widget:
  // InputWidget(
  //   world: app.world,
  //   child: GameWidget(app: app),
  // )
}
0
likes
0
points
408
downloads

Publisher

verified publisherfledge-framework.dev

Weekly Downloads

Input handling plugin for the Fledge ECS game framework. Provides action-based input mapping with keyboard, mouse, and gamepad support.

Homepage
Repository (GitHub)
View/report issues

Topics

#ecs #game-engine #input #gamepad #flutter-games

License

unknown (license)

Dependencies

fledge_ecs, flutter, gamepads, meta

More

Packages that depend on fledge_input