flame_spatial_grid 0.9.1 flame_spatial_grid: ^0.9.1 copied to clipboard
Spatial partitioning of game field to improve performance of collision detection and rendering
This library is a framework and set of tools for working with infinite game fields, loading infinite maps for one game level, creating an infinite count of game objects and active game players and NPCs - as much as possible.
The framework is fully compatible with Flame and does not contain any strict requirements for the game structure. Even existing games could be migrated to this framework if necessary.
This is still in beta. API and whole architecture might be changed at any time, including breaking changes.
There are a lot of utility functions and the list of its features is too long to describe at a fast glance. So here is a list of only top-level features:
- Building endless game levels without the need to change the screen for rendering another map. System gives you the ability to create big open worlds with seamless loading of new maps while a player approaches to them.
- Build game levels with a destructible environment. Every Tiled tile could be converted into separate game component and handle interactions with other game elements individually
- Building procedural-generated pieces of a map (or whole maps) on the fly, as the player approaches to them.
- Wise resource management: the system does not eat resources greedily, it takes care of proper allocation and de-allocation so you can enjoy your game even in a browser or weak mobile phone.
- New visual effects: lean resource management system allows to create trails for many players and persists during a long game session, blending with other game elements like ground.
Some of possible features might still be undiscovered :-)
Core concepts #
The core of the framework is a spatial grid that is building on-the-fly and controls component's visibility and activity, loads and unloads maps by chunks. It allows optimizing rendering by pre-rendering statical components into images, but keeps images size small enough and unloads unused chunks from memory.
Usage: minimal setup #
HasSpatialGridFrameworkmixin into you game
HasGridSupportmixin to every game component
initializeSpatialGridat your game's
onLoadfunction before adding any component into game.
See detailed "minimal start" tutorial at Getting Started section.
Future usage instructions #
- Getting Started Guide, if you still did not read it
- Working with Tiled maps
- Working with Tiled worlds
- Optimizing static objects rendering and collisions using CellLayers
- Interacting with Flame's Cameras
- [TODO] Creating trails and other temporary marks on the ground.
Advanced section #
- [TODO] How custom collision detection system works
- [TODO] How CellLayers optimizes collision detection.