mini_sprite 0.1.0 copy "mini_sprite: ^0.1.0" to clipboard
mini_sprite: ^0.1.0 copied to clipboard

A simple sprite format for building 1bit styled graphics.

mini_sprite #

style: very good analysis License: MIT

A simplified sprite format meant for 1bit styled games.

How to use #

Add mini sprite to your project pubspec:

dart pub add mini_sprite

MiniSprite #

MiniSprite holds the information for a single sprite, it can be generated at runtime or be loaded from its raw format:

Generating at runtime #

List<List<int>> _generatePixels() {
  // ...
}

final miniSprite = MiniSprite(_generatePixels());
print(miniSprite.pixels);

Reading from its raw format #

const spriteData = '...';
final miniSprite = MiniSprite.fromDataString(spriteData);
print(miniSprite.pixels);

Each value on the matrix represents a color index on a palette, where -1, means an unfilled pixel.

MiniLibrary #

MiniLibrary is a class that represents a collection of MiniSprites. It is a helper class that makes it easy to store and load a collection of sprites.

Just like MiniSprite it can be generated at runtime or loaded from its raw format.

Generating at runtime #

List<List<1>> _generatePixels() {
  // ...
}

final miniLibrary = MiniLibrary({
  'player': MiniSprite(_generatePixels()),
  'tile': MiniSprite(_generatePixels()),
});
print(miniLibrary.sprites);

Reading from its raw format #

const libraryData = '...';
final miniLibrary = MiniLibrary.fromDataString(libraryData);
print(miniLibrary.sprite);

MiniMap #

MiniMap is a class that holds information for a map (or stage) of a game. Its coordinate system is grid based and contains a collections of objects.

Objects are stored in a Map where the key is a MapPosition (a simple object that holds the x and y with the index of the object on the map grid) and the value is a map of the properties of the object.

With the exception of the sprite key on the properties, which holds the sprite name from a MiniLibrary, all other properties are custom values set in the editor.

Just like the other classes it can be generated at runtime or loaded from its raw format.

Generating at runtime #

final miniMap = MiniMap({
  MapPosition(2, 2): {
    'sprite': 'player',
  },
  MapPosition(2, 3): {
    'sprite': 'ground',
  },
  MapPosition(4, 3): {
    'sprite': 'spikes',
    'damage': 'fatal',
  },
});

Reading from its raw format #

const mapData = '...';
final miniMap = MiniMap.fromDataString(mapData);
2
likes
120
pub points
42%
popularity

Publisher

verified publisherblue-fire.xyz

A simple sprite format for building 1bit styled graphics.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

equatable

More

Packages that depend on mini_sprite