flutterxel 0.0.4 copy "flutterxel: ^0.0.4" to clipboard
flutterxel: ^0.0.4 copied to clipboard

Flutter runtime plugin for a Pyxel-compatible engine backed by Rust FFI.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutterxel/flutterxel.dart' as flutterxel;

const double _spriteSize = 16;
double _x = 0;
double _vx = 1.5;

void main() {
  flutterxel.init(160, 120, title: 'flutterxel example', fps: 60);

  flutterxel.run(
    () {
      if (flutterxel.btn(flutterxel.KEY_LEFT)) {
        _x -= 2.0;
      }
      if (flutterxel.btn(flutterxel.KEY_RIGHT)) {
        _x += 2.0;
      }

      _x += _vx;
      if (_x <= 0 || _x >= flutterxel.width - _spriteSize) {
        _x = _x.clamp(0, flutterxel.width - _spriteSize);
        _vx = -_vx;
      }
    },
    () {
      flutterxel.cls(1);
      flutterxel.blt(_x, 52, 0, 0, 0, _spriteSize, _spriteSize, colkey: 2);
      flutterxel.blt(
        flutterxel.width - _x - _spriteSize,
        72,
        0,
        0,
        0,
        -_spriteSize,
        _spriteSize,
        colkey: 2,
      );
    },
  );

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    final version =
        '${flutterxel.Flutterxel.versionMajor()}.'
        '${flutterxel.Flutterxel.versionMinor()}.'
        '${flutterxel.Flutterxel.versionPatch()}';

    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('flutterxel example')),
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              const flutterxel.FlutterxelView(pixelScale: 3),
              const SizedBox(height: 16),
              Text(
                'flutterxel core ABI v$version\n'
                'screen: ${flutterxel.width}x${flutterxel.height}',
                textAlign: TextAlign.center,
              ),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
0
points
268
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter runtime plugin for a Pyxel-compatible engine backed by Rust FFI.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

ffi, flutter, image, plugin_platform_interface

More

Packages that depend on flutterxel

Packages that implement flutterxel