Giter Club home page Giter Club logo

flame_isometric's Introduction

Flame Isometric

Generate matrix for IsometricTileMapComponent

Flutter Pub MIT Licence GitHub stars pub points

The matrix required to render an isometric tile map using the IsometricTileMapComponent in Flame, Flutter's frame game engine. This plugin generates the

Usage

import IsometricTileMapComponent Class

The Flame 1.6.0 version of IsometricTileMapComponent does not provide an interface to easily import tile maps generated by the Tiled Map Editor, but rather generates them using tilesetImage and matrix. The interface is generated by tilesetImage and matrix.

So, using 'package:tiled/tiled.dart' and 'package:flame/sprite.dart', we analyze the tmx data with TileMapParser and create a matrix, The matrix is then adjusted to match the SpriteSheet index, and the tileset is generated by the SpriteSheet component. By passing the matrix and tileset to IsometricTileMapComponent, an IsometricMap is rendered.

They are handled by the FlameIsometric class, which can be generated by passing the tileMap image path and the tmx file path.

final flameIsometric = await FlameIsometric.create(tileMap: 'tile_map.png', tmx: 'tiles/tile_map.tmx');

The matrix is generated layer by layer, and the matrices for all layers are stored in the matrixList of the flameIsometric instance.

Rendering is performed in layer order using for statements, etc.

for (var i = 0; i < flameIsometric.layerLength; i++) {
  add(
    IsometricTileMapComponent(
      flameIsometric.tileset,
      flameIsometric.renderMatrixList[i],
      destTileSize: flameIsometric.srcTileSize,
      position: Vector2(gameSize.x / 2, flameIsometric.tileHeight.toDouble()),
    ),
  );
}

tileset Multiple support

Multiple tilesets are also supported.

Specify a tileMap with a List as the argument, and tsxList also specifies a List as the argument.

Please note that tsxList is required in this case.

final flameIsometric = await FlameIsometric.create(
    tileMap: ['tile_map.png', 'tile_map2.png'],
    tsxList: ['tiles/tile_map.tsx', 'tiles/tile_map2.tsx'],
    tmx: 'tiles/tile_map2.tmx'
);

One is a tileset of size 64x64.

The other is to use a tileset of size 128x128 and tilesets of different sizes.

When combined, the tiled map looks like this. You can use this map to adapt the game engine to use the Flame game engine.

Using CustomIsometricTileMapComponent

The exact layer containing multiple tile chips is stored in renderLayerList and can be retrieved by specifying it with a for statement.

A custom version of IsometricTileMapComponent, called CustomIsometricTileMapComponent, can be used for easy rendering.

for (var renderLayer in flameIsometric.renderLayerList) {
  add(
    CustomIsometricTileMapComponent(
      renderLayer.spriteSheet,
      renderLayer.matrix,
      destTileSize: flameIsometric.srcTileSize,
      position:
      Vector2(gameSize.x / 2, flameIsometric.tileHeight.toDouble()),
    ),
  );
}

:::note warn Tile sets of different sizes can be displayed, but the position of the tileset to be drawn is misaligned and still needs to be adjusted. :::

These sample sources can be found here.

Create Reference

Use the Tiled Map Editor to create an Isometric tile map.

In this case, Flame 1.6.0 does not seem to support rectangular maps, so "Isometric" (not Isometric (Staggered)) must be selected for Orientation.

Select a map of the following shape.

As for tile sets, they are mapped in squares.

This time, we are using materials created by Seth Galbraith from OpenGameArt.org, a website that provides free materials.

Layers

As for layers, they are placed in three separate layers: "bottom," "middle," and "top.

Mainly, the floor is placed in the "bottom" layer. The "middle" layer is for walls, etc. The "top" layer is mainly used for roofs, and the map is created as shown below.

Contributor

copyright holder

isometric-64x64-medieval-building-tileset : Seth Galbraith

basic isometric tiles 128x128 : ToxSickProductions.com

I appreciate it very much.

Author

Daisuke Takayama

flame_isometric's People

Contributors

panicdragon avatar ccn-takayama-daisuke avatar

Stargazers

Raku Xaster avatar Cristovão Farias avatar  avatar Aymen Dennoub avatar Ko Htut avatar  avatar

Watchers

 avatar web帳 avatar Kostas Georgiou avatar

Forkers

ko-htut

flame_isometric's Issues

Only rendering single tileset

I have a tilemap with multiple isometric tilesets, and I followed the example project. But I am not able to load multiple tilesets on my map and it's only loading the ground layer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.