lafriks / go-tiled Goto Github PK
View Code? Open in Web Editor NEWGo library to parse Tiled map editor file format (TMX) and render map to image
License: MIT License
Go library to parse Tiled map editor file format (TMX) and render map to image
License: MIT License
go-tiled
currently has no functionality to load infinite maps and will panic when this is attempted:
panic: illegal base64 data at input byte 0
Hello!
I appreciate the framework that you made available for importing Tiled maps, and I appreciate the provided orthographic Renderer as well!
I was wondering, though, why the image itself isn't available for usage without saving it out to a file? It seems like it would be trivial to expose the Renderer's img property so that one could immediately use it (in my case, for a game)? If this is fine, I could make the change and send a PR.
Just wanted to get some insight as to the reason behind not making it available for this - thanks again, for your framework here!
Hi!
I can't seem to load from embedded storage.
The folder structure looks like this:
assets
|
|
|__ images
| |
| |__ world.png
|
|__ maps
| |
| |__ level1.tmx
|
|__ tilesets
|
|__ world.tsx
level1.tmx
refers to ../tilesets/world.tsx
and world.tsx
refers to ../images/world.png
.
The assets are embedded using Go 1.16 Embed syntax:
//go:embed assets/*
var assets embed.FS
I can load files just fine using assets
methods. According to the documentation (and the source-code), the regular "LoadFromFile" method uses a nil-loader. A nil-loader uses the default os
-Loader.
Alternative should be, to use a custom Loader
. And then use it to load the map.
loader := tiled.Loader{FileSystem: http.FS(assets)}
f, err := assets.Open("assets/maps/" + filename)
if err != nil {
log.Fatal(err)
}
level, err = loader.LoadFromReader("", f)
if err != nil {
log.Fatal(err)
}
This results in open assets\tilesets\world.tsx: file does not exist
.
Loading the map using LoadFromFile
instead, manages to find the tileset. But not the image used in the tileset.
The situation is even worse in this case, as it tries to load from the absolute path:
open C:\Users\Chris\Projects\TMXDemo\assets\maps\assets\tilesets\world.tsx: file does not exist
.
Embedding the tileset into the map however works like a charm.
Any ideas how to fix this?
I've noticed that in some cases you define default values for the struct interface. For example in the text unmarshal function
type Alias Text
item := Alias{
FontFamily: "sans-serif",
Size: 16,
Kerning: true,
HAlign: "left",
VAlign: "top",
}
What is the purpose of those defaults? I would like to use go-tiled as a tool to read/write Tiled files and these defaults may cause weird situations if they differ from what Tiled defines.
My preference is to display what is defined in the .tmx/.tsx files without modifications or assumptions. providing an easy interface for special values like layer tiles.
Thank you
type Map struct {
// ...
// For staggered and hexagonal maps, determines which axis ("x" or "y") is staggered. (since 0.11)
StaggerAxis int `xml:"staggeraxis,attr"`
// For staggered and hexagonal maps, determines whether the "even" or "odd" indexes along the staggered axis are shifted. (since 0.11)
StaggerIndex int `xml:"staggerindex,attr"`
}
The StaggerAxis
and StaggerIndex
should be string instead of int.
The tmx
content would be like:
<map version="1.9" tiledversion="1.9.2" orientation="hexagonal" renderorder="right-down" width="30" height="20" tilewidth="32" tileheight="32" infinite="0" hexsidelength="16" staggeraxis="y" staggerindex="odd" nextlayerid="2" nextobjectid="1">
......
</map>
Giving an object a string property which value contains a multiline string (containing \n
) results in the string being empty.
This is because Tiled will no longer use the Value
attribute and instead use the inner XML instead.
Currently image source is loaded relative from map base directory
Hey Lafriks,
I love your project! I'd like to use it with ebiten and WebASM which requires the recent embedded file change. Would you be okay pushing a new tag?
Thank you!
Hi,
I found your library today, and it seems great. If I embedd the tilesheet in tile, it works fine, but can I do it without embedding?
goroutine 1 [running]: github.com/lafriks/go-tiled/render.(*Renderer).getTileImage(0xc000068840, 0xc0000f3b40, 0x0, 0x0, 0x0, 0x0) /Users/test/go/src/github.com/lafriks/go-tiled/render/renderer.go:86 +0x1c4 github.com/lafriks/go-tiled/render.(*Renderer).RenderLayer(0xc000068840, 0x0, 0xc0, 0xc000068840) /Users/test/go/src/github.com/lafriks/go-tiled/render/renderer.go:153 +0xe8 github.com/lafriks/go-tiled/render.(*Renderer).RenderVisibleLayers(0xc000068840, 0xc000068840, 0x0) /Users/test/go/src/github.com/lafriks/go-tiled/render/renderer.go:181 +0x79 main.run() /Users/test/go/src/github.com/kyeett/dungeon/main.go:34 +0x18d main.main() /Users/test/go/src/github.com/kyeett/dungeon/main.go:51 +0x20 exit status 2
Hi!
The decoding the following code+map fails with cannot unmarshal into tiled.Point
. I haven't been able to pinpoint the reason.
Code (main.go)
func New(path string) {
m, err := tiled.LoadFromFile("assets/maps/polygon.tmx")
if err != nil {
log.Fatal("load map ", err)
}
fmt.Printf("%#v\n", m.ObjectGroups[0])
}
Map: (assets/maps/polygon.tmx)
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.2" tiledversion="1.2.1" orientation="orthogonal" renderorder="right-down" width="4" height="4" tilewidth="16" tileheight="16" infinite="0" nextlayerid="3" nextobjectid="3">
<layer id="1" name="Tile Layer 1" width="4" height="4">
<data encoding="csv">
0,0,0,0,
0,0,0,0,
0,0,0,0,
0,0,0,0
</data>
</layer>
<objectgroup id="2" name="paths">
<object id="2" x="9" y="46">
<polyline points="1,1 23,-8 24,-7 40,4 50,-10"/>
</object>
</objectgroup>
</map>
Load failed,"strconv.ParseInt: parsing "15.52": invalid syntax"
<imagelayer id="20" name="bg" opacity="0.61" offsetx="15.52" offsety="30.18"/>
Hi,
Thanks a lot for this library. I was wondering if in the following LOC:
https://github.com/lafriks/go-tiled/blob/v0.3.0/tmx_layer.go#L238
TileWidth and TileHeight are swapped? Perhaps it should be the following?
return l.OffsetX + xl._map.TileWidth, l.OffsetY + yl._map.TileHeight
Thanks,
Jose
want to create colliders around map border using a polygon from tiled
Append this part to any tmx file to make loading fail
<object id="8" x="465.333" y="410.667">
<polygon points="0,0 14.6667,1.33333 30,-8.66667 33.3333,-80.6667 27.3333,-96 14,-104 15.3333,-124.667 24.6667,-134.667 36,-140.667 48,-140.667 76,-140.667 93.3333,-151.333 102,-166.667 116.667,-178.667 126,-186 144,-187.333 154.667,-185.333 163.333,-182.667 170.667,-176 175.333,-157.333 180.667,-148 187.333,-143.333 208,-135.333 218,-127.333 227.333,-122.667 248.667,-121.333 266,-121.333 294,-120 312.667,-115.333 320.667,-101.333 318,-95.3333 311.333,-83.3333 297.333,-68 285.333,-57.3333 268.667,-42 260.667,-27.3333 254.667,-26 254,-11.3333 284,22.6667 287.333,43.3333 287.333,49.3333 344.667,47.3333 346.667,75.3333 284,76.6667 274.667,92.6667 260,98.6667 249.333,100 242,84 218.667,84.6667 206,102.667 173.333,101.333 162,82.6667 138.667,82 111.333,112.667 93.3333,113.333 76,95.3333 59.3333,98.6667 46.6667,118 43.3333,148.667 31.3333,160.667 -2.66667,162.667 -30,131.333 -52,132.667 -66.6667,148.667 -66.6667,176.667 -95.3333,208.667 -128.667,212 -239.333,100.667 -242.667,66 -270,35.3333 -308,35.3333 -320,52 -356,51.3333 -386.333,24.3333 -386.333,2.33333 -337.333,-42.6667 -322.333,-40.6667 -304.333,-58.6667 -275.333,-56.6667 -232.333,-15.6667 -193.333,-8.66667 -176.333,3.33333 -178.333,29.3333 -192.333,52.3333 -193.333,81.3333 -167.333,99.3333 -138.333,95.3333 -128.333,80.3333 -129.333,39.3333 -116.333,22.3333 -113.333,2.33333 -175.333,-62.6667 -197.333,-60.6667 -204.333,-75.6667 -206.333,-92.6667 -194.333,-104.667 -162.333,-136.667 -121.333,-137.667 -120.333,-196.667 -92.3333,-194.667 -90.3333,-130.667 -52.3333,-132.667 -35.3333,-110.667 -21.3333,-94.6667 -17.3333,-13.6667"/>
</object>
Hi,
I am seeing some parse errors in go-tiled v0.9.0. I believe this is the result of PR #55.
How to reproduce: I created a super basic tileset using Tiled 1.9.1 with a terrain (aka wangset). This is the final file:
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.9" tiledversion="1.9.1" name="TEST" tilewidth="32" tileheight="32" tilecount="3600" columns="60">
<image source="samplemap.png" width="1920" height="1920"/>
<wangsets>
<wangset name="Unnamed Set" type="corner" tile="-1">
<wangcolor name="" color="#ff0000" tile="-1" probability="1"/>
</wangset>
</wangsets>
</tileset>
Tiled is using -1
in the tile
attribute of both wangset
and wangcolor
. I thought -1
was an invalid value for the tile
attribute, but I looked into the source code for Tiled and the wangset imageTileId
is an int
(not a uint32
) and it defaults to -1
:
https://github.com/mapeditor/tiled/blob/6ad9e7136fedc80940819ab44a7b55bffa6b8beb/src/libtiled/wangset.h#L241
Likewise, the wangcolor imageId
is also an int
(not a uint32
) and it defaults to -1
:
https://github.com/mapeditor/tiled/blob/6ad9e7136fedc80940819ab44a7b55bffa6b8beb/src/libtiled/wangset.h#L185
When I try to parse the tsx file above with go-tiled v0.9.0, it fails with the following error:
strconv.ParseUint: parsing "-1": invalid syntax
I believe what happens is that go-tiled is trying to parse the -1
into a uint32
(e.g., the WangSet.TileID field) and it fails for this reason.
I suspect that the Wangset.TileID
and the Wangcolor.TileID
should be int
instead of uint32
. Perhaps there are other TileID
that should also be int
but I didn't check.
What do you think?
Thanks,
Jose
Hey, I decided to use go-tiled for a project of mine by using ebitenengine, I designed my map and put it where it should be as a .tmx file, but now I'm getting this error.
func getTiled(name string) *ebiten.Image {
gameMap, err := tiled.LoadFile(name)
if err != nil {
fmt.Printf("error parsing map: %s", err.Error())
os.Exit(2)
}
fmt.Println(gameMap)
renderer, err := render.NewRenderer(gameMap)
if err != nil {
fmt.Printf("map unsupported for rendering: %s", err.Error())
os.Exit(2)
}
// Render just layer 0 to the Renderer.
err = renderer.RenderLayer(0)
if err != nil {
fmt.Printf("layer unsupported for rendering: %s", err.Error())
os.Exit(2)
}
// Get a reference to the Renderer's output, an image.NRGBA struct.
img := renderer.Result
// Clear the render result after copying the output if separation of
// layers is desired.
renderer.Clear()
return ebiten.NewImageFromImage(img)
}
var Tile = getTiled("./assets/Sprites/tile.tmx")
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.10.2" orientation="orthogonal" renderorder="right-down" width="120" height="68" tilewidth="16" tileheight="16" infinite="1" nextlayerid="2" nextobjectid="1">
<tileset firstgid="1" source="tilemap.tsx"/>
<layer id="1" name="Tile Layer 1" width="120" height="68">
<data encoding="csv">
<chunk x="-16" y="-16" width="16" height="16">
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,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,1
</chunk>
</data>
</layer>
</map>
From what I can gleam from the source, despite the fact that the fields in the struct denote default values, they don't seem to be implemented on Objects yet.
I notice that the Unmarshal methods tend to be where the defaults are set, and I don't see that implemented for the Object at this point. Thus, any values written into the TMX file show up, but when something is set to the Tiled default, it doesn't write it to the TMX file. The visible property is the most noticeable one, but I am sure there are others.
I presume implementing that aspect similar to the other items would help this to actually behave as expected.
This is probably similar to another task to review default values, provided the appropriate Unmarshal method is put in place and used.
I get "unsupported orientation" when trying to render a map using this orientation
Code in readme is no longer valid but has great comments.
Code in example folder is great but lacks the beginner friendly comments.
Consider pointing readme to example file or minimally updating README's newrenderer call to match current signature.
Hello, I found a problem in the operation of one of the UnmarshalXML in Map.
This code will cause os.ErrNotExist
on windows for data/world/surface-tileset.tmx
even if the file is there:
//go:embed data
var fs embed.FS
...
// File surface.tmx has reference to surface-tileset.tmx in it.
tiled.LoadFile("data/world/surface.tmx", tiled.WithFileSystem(fs))
The library allows you to insert your own fs implementation to upload files:
https://github.com/lafriks/go-tiled/blob/main/tiled.go#L76
In the process, it loads additional files (for example, tileset) for which it builds a path as follows:
https://github.com/lafriks/go-tiled/blob/main/tmx_map.go#L173
Which will return the path with windows-like slashes data\world\surface-tileset.tmx
. This path will not work with embed:
golang/go#44305
Despite the fact that these are details of the implementation of a specific fs, it is part of the standard library.
So it makes sense to take these details into account inside the lib.
Add a wrapper that converts paths in special cases.
func WithFileSystem(fileSystem fs.FS) LoaderOption {
return func(l *loader) {
l.FileSystem = fileSystem
if _, ok := l.FileSystem.(*embed.FS); ok {
l.FileSystem = WithPathRelative(FileSystem)
}
}
}
type PathRelativeFS struct {
fs fs.FS
}
func WithPathRelative(fs fs.FS) fs.FS {
return &PathRelativeFS{fs}
}
func (p *PathRelativeFS) Open(name string) (fs.File, error) {
name = strings.Replace(name, string(filepath.Separator), "/", -1)
return p.fs.Open(name)
}
Add the option to use path.Join
instead of filepath.Join
for special occasions.
func (m *Map) GetFileFullPath(fileName string) string {
if _, ok := m.loader.FileSystem.(*embed.FS); ok {
return path.Join(m.baseDir, fileName)
}
return filepath.Join(m.baseDir, fileName)
}
Looks like it the same as #63.
Just to be aware, This is something that should be easy to implement.
Link to the docs https://doc.mapeditor.org/en/stable/reference/tmx-map-format/#tile-flipping
It would be nice to have the branch release/v0.3.0 so we can merge the breaking pull request into it.
Maybe we can establish some functional requirements to reach v0.3.0, or just a time limit.
The method Map.TileGIDToTile is overkill when you need to perform basic checking for actual GID, HFlip, VFlip, etc. These should be separated out into utility methods, additionally the flip masks should be public constants for use in application code.
If I have time, I will do this.
I'm not sure if this is intended behaivor, I'm new to Tiled, but whenever I try to render this .tmx
file
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.4" tiledversion="1.4.2" orientation="orthogonal" renderorder="right-down" width="9" height="9" tilewidth="128" tileheight="128" infinite="0" nextlayerid="6" nextobjectid="24">
<tileset firstgid="1" source="../assets/kenney_tiles.tsx"/>
<layer id="3" name="Background" width="9" height="9">
<data encoding="csv">
...
</data>
</layer>
<layer id="1" name="Main" width="9" height="9">
<data encoding="csv">
...
</data>
</layer>
<objectgroup id="4" name="Trees">
<object id="15" gid="345" x="385.697" y="521.545" width="141" height="141"/>
<object id="18" gid="345" x="627.818" y="656.697" width="141" height="141"/>
<object id="19" gid="345" x="433.03" y="786.152" width="141" height="141"/>
<object id="21" gid="318" x="191.97" y="100.697" width="210" height="62"/>
<object id="22" gid="317" x="770.758" y="1100.7" width="210" height="62"/>
</objectgroup>
</map>
Hello,
first time Golang and game dev here so this is more of a question than a bug report :)
I'm facing an issue where image.NRGBA
produced by rend.RenderVisibleLayers()
is not aligned with objects from the tiled.ObjectGroup
. They seem flipped vertically. I am using the pixel
2d library for rendering.
This is what my Tiled
editor looks like:
And this is The result I get after rendering everything without moving or scaling things:
Purple lines indicate the (0, 0) point.
Red boxes are representing where the ObjectGroup
objects are.
Why are objects flipped compared to the rendered map and the compared to how they look in the editor?
Is this the expected behaviour or am I doing something wrong?
Any help would be greatly appreciated :)
func TestLoadBigMapFromTiled(t *testing.T) {
tiledDirectory :=`xxxxxxxxxxxxxxxx`
bigMapUrl := tiledDirectory + `/BigMap.tmx`
// Parse .tmx file.
gameMap, err := tiled.LoadFile(bigMapUrl)
if err != nil {
panic(err)
}
fmt.Println(gameMap)
}
The error is "illegal base64 data at input byte 0".
And is go-tiled stop updating?
I am so confused, because I see the last update time of go-tiled is 2023/03, but the basic load .tmx file functionality is not support.
Hello!
I believe tiles are being rotated incorrectly for the orthographic renderer - can you confirm if what I'm seeing is what you see with rotated tiles in a TMX map as well? If so, I can submit a PR. Here's an example of what I'm seeing with a relatively simple TMX file I have.
Here's a screenshot showing the issue after rendering the result to an image and then drawing it to the screen using ebiten:
The tiles are rotated improperly, though it seems that horizontally or vertically flipped tiles are transformed properly. The tiles are correct after I tweaked the OrthogonalRendererEngine.RotateTileImage function:
Here's the change I made:
// RotateTileImage rotates provided tile layer.
func (e *OrthogonalRendererEngine) RotateTileImage(tile *tiled.LayerTile, img image.Image) image.Image {
timg := img
if tile.HorizontalFlip {
timg = imaging.FlipH(timg)
}
if tile.VerticalFlip {
timg = imaging.FlipV(timg)
}
if tile.DiagonalFlip {
//This was "timg = imaging.FlipH(imaging.Rotate270(timg))"
timg = imaging.FlipH(imaging.Rotate90(timg))
}
return timg
}
It seems like this is a rather simple solution to get the tiles to transform properly.
Hello
I've used go-tiled in my Ebiten project and had to rewrite most of the tile.Renderer
to get 60 FPS and reduce the number of allocations/copying.
I think I can implement a new example/renderer which will use *ebiten.Image
instead of image.Image
and allow users to see how to quickly insert go-tiled into their Ebiten project.
Is there any interest in that?
P.S. I feel like current renderer should either be made more generic (e.g. have it use interfaces and not render to image.Image directly) and most of "direct to image" functionality should be moved to an example. So, either renderer should be general-purpose and extendable or it should be just an example, because I feel like current implementation is not extendable enough.
Looking at the documentation for tiled.Layer
,
// This is the attribute you'd like to use, not Data. Tile entry at (x,y) is obtained using l.DecodedTiles[y*map.Width+x].
Tiles []*LayerTile
we are instructed to use l.DecodedTiles
which doesn't exist on the tiled.Layer
struct. What Is the intended way to access the actual decoded tiles?
Hello, when go-tiled attempts to load a .tsx file referenced by a .tmx file, it will not use the required type of filepath slashes when using an embedded filesystem via WithFileSystem
. This causes issues when running on Windows.
See the following commit for a workaround I found. I hope it assists with identifying a better fix.
TMX maps contain object groups that can be of several types, such as, rectangles, points, etc. One of these types is a tile object, which are objects that have a GID field. If this field is set then the GID refers to a tile within a tileset. If the tileset is used by a tile object but otherwise not used in any of the layers, then the library will not load this tileset.
The following proposal extends the decoding logic to include decoding for object groups also. To decode an object group, all objects contained in the object group are traversed and in case the object has a GID set, then the corresponding tileset is initialized by calling TileGIDToTile, which is also the strategy used by layer decoding.
Proposal: master...jabolopes:tileobjects
if .tmx has tile ids beyond 1000s the program panic with nil pointer diff
Having a hard time wrapping my head around this library / the XML spec for Tiled - https://doc.mapeditor.org/en/stable/reference/tmx-map-format/#object, mind providing an example?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.