-
-
Notifications
You must be signed in to change notification settings - Fork 1k
feat: Introduce flame_typled #3862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # flame_typled | ||
|
|
||
| flame_typled provides integration between [Typled](https://pub.dev/packages/typled) sprite atlases | ||
| and Flame. | ||
|
|
||
| Typled is simple text based format to map sprite sheets, tile sets and tile maps. It provides a dart | ||
| package to parse the text files into usable dart models and an application to allow visualization of | ||
| the files. | ||
|
|
||
| Import the `TypledSpriteAtlas` class from `'package:flame_typled/flame_typled.dart'` and load your | ||
| atlas: | ||
|
|
||
| ```dart | ||
| final atlas = await TypledSpriteAtlas.load('assets/atlas.typled'); | ||
| ``` | ||
|
|
||
| Then retrieve individual sprites by their typled id: | ||
|
|
||
| ```dart | ||
| final mySprite = atlas.sprite('player_idle'); | ||
| ``` | ||
|
|
||
| Note that this will create a new instance of Sprite, so you might want to save it. | ||
|
|
||
| Or create a `SpriteBatch` for efficient batch rendering: | ||
|
|
||
| ```dart | ||
| final batch = atlas.toBatch(useAtlas: false); | ||
| ``` | ||
|
|
||
| By default, Flame Typled will add a Ghost Line busting padding of 1 pixel all around | ||
| (2 pixels total) for each tile. You can change this by passing `disablePadding: true` | ||
| to the `TypledSpriteAtlas.load()`. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2026 Blue Fire | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| <!-- markdownlint-disable MD013 --> | ||
| <p align="center"> | ||
| <a href="https://flame-engine.org"> | ||
| <img alt="flame" width="200px" src="https://user-images.githubusercontent.com/6718144/101553774-3bc7b000-39ad-11eb-8a6a-de2daa31bd64.png"> | ||
| </a> | ||
| </p> | ||
|
|
||
| <p align="center"> | ||
| Adds support for loading <a href="https://pub.dev/packages/typled">Typled</a> sprite atlases as Sprites in your <a href="https://github.com/flame-engine/flame">Flame</a> games. | ||
| </p> | ||
|
|
||
| <p align="center"> | ||
| <a title="Pub" href="https://pub.dev/packages/flame_typled" ><img src="https://img.shields.io/pub/v/flame_typled.svg?style=popout" /></a> | ||
| <a title="Test" href="https://github.com/flame-engine/flame/actions?query=workflow%3Acicd+branch%3Amain"><img src="https://github.com/flame-engine/flame/actions/workflows/cicd.yml/badge.svg?branch=main&event=push"/></a> | ||
| <a title="Discord" href="https://discord.gg/pxrBmy4"><img src="https://img.shields.io/discord/509714518008528896.svg"/></a> | ||
| <a title="Melos" href="https://github.com/invertase/melos"><img src="https://img.shields.io/badge/maintained%20with-melos-f700ff.svg"/></a> | ||
| </p> | ||
|
|
||
| --- | ||
|
|
||
| <!-- markdownlint-enable MD013 --> | ||
|
|
||
| <!-- markdownlint-disable-next-line MD002 --> | ||
|
|
||
| # flame_typled | ||
|
|
||
| Package to add Typled sprite atlas support Flame's sprites. | ||
|
luanpotter marked this conversation as resolved.
|
||
|
|
||
| Typled is simple text based format to map sprite sheets, tile sets and tile maps. It provides a dart | ||
| package to parse the text files into usable dart models and an application to allow visualization of | ||
| the files. | ||
|
|
||
| More [here](https://docs.flame-engine.org/main/bridge_packages/flame_typled/flame_typled.html). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| include: package:flame_lint/analysis_options_with_dcm.yaml | ||
|
|
||
| linter: | ||
| rules: | ||
| - public_member_api_docs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # flame_typled example | ||
|
|
||
| A simple example of how to use the `flame_typled` package. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| include: package:flame_lint/analysis_options.yaml |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions
19
packages/flame_typled/example/assets/mini-dungeon.typled_atlas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| [atlas] | ||
| imagePath = mini-dungeon.png | ||
| tileSize = 8 | ||
|
|
||
| [sprites] | ||
| top_left_dirt = 0, 0 | ||
| top_middle_dirt = 1, 0 | ||
| top_right_dirt = 2, 0 | ||
|
|
||
| green_globin = 0, 4 | ||
| red_globin = 1, 4 | ||
|
|
||
| rock = 0, 3 | ||
|
|
||
| tree_leaves = 1, 5, 3, 3 | ||
|
|
||
| [hitboxes] | ||
| rock = 3, 6, 3, 2 | ||
| red_globin = 2, 3, 4, 4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import 'dart:async'; | ||
|
|
||
| import 'package:flame/components.dart'; | ||
| import 'package:flame/game.dart'; | ||
| import 'package:flame_typled/flame_typled.dart'; | ||
| import 'package:flutter/material.dart'; | ||
|
|
||
| void main() { | ||
| runApp(const MyApp()); | ||
| } | ||
|
|
||
| class MyApp extends StatelessWidget { | ||
| const MyApp({super.key}); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return const MaterialApp( | ||
| home: GameWidget.controlled( | ||
| gameFactory: TypledExample.new, | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class TypledExample extends FlameGame { | ||
| @override | ||
| Color backgroundColor() => const Color(0xFF2A1D3A); | ||
|
|
||
| @override | ||
| Future<void> onLoad() async { | ||
| final atlas = await TypledSpriteAtlas.load('mini-dungeon.typled_atlas'); | ||
| final scale = Vector2.all(16); | ||
|
|
||
| add( | ||
| SpriteComponent( | ||
| sprite: atlas.sprite('rock'), | ||
| position: Vector2(50, 50), | ||
| scale: scale, | ||
| ), | ||
| ); | ||
| add( | ||
| SpriteComponent( | ||
| sprite: atlas.sprite('green_globin'), | ||
| position: Vector2(200, 220), | ||
| scale: scale, | ||
| ), | ||
| ); | ||
| add( | ||
| SpriteComponent( | ||
| sprite: atlas.sprite('red_globin'), | ||
| position: Vector2(10, 300), | ||
| scale: scale, | ||
| ), | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| name: flame_typled_example | ||
| resolution: workspace | ||
| description: "An example for the TypledSpriteAtlas." | ||
|
|
||
| publish_to: "none" | ||
|
|
||
| version: 1.0.0+1 | ||
|
|
||
| environment: | ||
| sdk: ">=3.11.0 <4.0.0" | ||
|
|
||
| dependencies: | ||
| flame: ^1.36.0 | ||
| flame_typled: ^0.1.0 | ||
| flutter: | ||
| sdk: flutter | ||
|
|
||
| dev_dependencies: | ||
| flame_lint: ^1.4.3 | ||
|
|
||
| flutter: | ||
| uses-material-design: false | ||
| assets: | ||
| - assets/images/ | ||
| - assets/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| library flame_typled; | ||
|
|
||
| export 'typled_sprite_atlas.dart'; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.