flame_spatial_grid 0.9.2 copy "flame_spatial_grid: ^0.9.2" to clipboard
flame_spatial_grid: ^0.9.2 copied to clipboard

Spatial partitioning of game field to improve performance of collision detection and rendering

example/lib/main.dart

import 'dart:ui';

import 'package:flame/game.dart';
import 'package:flame_spatial_grid/flame_spatial_grid.dart';
import 'package:flame_spatial_grid_example/game.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.purple,
      ),
      home: GameWidget.controlled(
        gameFactory: SpatialGridExample.new,
        overlayBuilderMap: {
          'loading': (BuildContext ctx, SpatialGridExample game) {
            return Material(
              type: MaterialType.transparency,
              child: BackdropFilter(
                filter: ImageFilter.blur(
                  sigmaX: 5.0,
                  sigmaY: 5.0,
                ),
                child: StreamBuilder<LoadingProgressMessage<String>>(
                  stream: game.loadingStream,
                  builder: (context, snapshot) {
                    final progress = snapshot.data?.progress ?? 0;
                    return Center(
                      child: Text(
                        'Loading: $progress% ',
                        style: const TextStyle(
                          color: Colors.white,
                          fontWeight: FontWeight.bold,
                          fontSize: 24,
                        ),
                      ),
                    );
                  },
                ),
              ),
            );
          },
        },
      ),
    );
  }
}
2
likes
110
pub points
41%
popularity

Publisher

verified publisherasgalex.pro

Spatial partitioning of game field to improve performance of collision detection and rendering

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

collection, dart_bloom_filter, flame, flame_tiled, flat_buffers, flutter, isolate_manager, js, meta, tiled, vector_math, xml

More

Packages that depend on flame_spatial_grid