solarlune / ldtkgo Goto Github PK
View Code? Open in Web Editor NEWLDtk-Go is a loader for LDtk projects written in Golang.
License: MIT License
LDtk-Go is a loader for LDtk projects written in Golang.
License: MIT License
I might be doing something wrong, but when I open a project, a level's layer list is empty.
I'm using LDtk version 1.5.3.
This is how I use ldtkgo:
p, err := ldtkgo.Open(*projectFilename)
if err != nil {
panic(err)
}
for _, level := range p.Levels {
for _, layer := range level.Layers {
// Never executed because Layers is [].
}
}
}
I can confirm that Level fields like Identifier are loaded correctly.
The Level has layers:
"layerInstances": [
{
"__identifier": "BottomTiles",
"__type": "Tiles",
"__cWid": 32,
"__cHei": 20,
"__gridSize": 16,
"__opacity": 1,
"__pxTotalOffsetX": 0,
...
I'm not sure why they're not unmarshalled into the ldtkgo.Level.Layers
.
Here is an LDtk project (it's just 1 level and a project file):
Ok, so I have a tile setup which looks like this:
The entiy in question is a switch, its sprite is the close switch (red). As long as I had it only that way, it rendered in the game as expected. However, then I added a Tile Property, as can be seen in the screenshot. In the game I load both sprites into different variables, but BOTH now point the SAME region in the tileset. When I render both sprites in the game it looks like this:
When I dump the entity.TileRect
without the tile property, I get:
2024-03-31T07:20.13 CEST DEBUG: LOAD TILE /home/scip/dev/openquell/game/levels.go: 188
isdoor: false
isswitch: true
name: Switch
tileid: 7d975370-d7b0-11ee-9add-971995295000
tilerect:
x: 96 <==
y: 160 <==
w: 32
h: 32
tilesetuid: 57
With the property I get:
2024-03-31T07:17.01 CEST DEBUG: LOAD TILE /home/scip/dev/openquell/game/levels.go: 188
isdoor: false
isswitch: true
name: Switch
tileid: 7d975370-d7b0-11ee-9add-971995295000
tilerect:
x: 96 <==
y: 192 <==
w: 32
h: 32
tilesetuid: 57
tileref: 81e502b0-d7b0-11ee-9add-6193c766edeb
togglerect:
x: 96 <== This is the location of the tile property sprite
y: 192 <==
w: 32
h: 32
However, I managed to "fix" this behavior by customizing the Display Setting of the property. By default it's value is Replace entity tile
. When I set it like so:
then everything works as expected.
Please correct me if I'm wrong, but in my opinion this is a bug: ldtkgo should not consider the display settings. I think these are meant for the LDTK UI only, not for the resulting game. Now that I know how to circumvent this, it's no real problem. But it took me a while to find.
I was trying to load a regular ldtk 0.6.1 file and i got this error :(
Go Version: go1.15.5 linux/amd64
OS: Void Linux Musl
Arch: x86_64
When you call PropertyByIdentifier
with a non-existing key, like so:
[..]
system.Print(system.Plan.PropertyByIdentifier("Description").AsString(), 10, 470)
[..]
then you get this:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x7b8564]
goroutine 34 [running]:
github.com/solarlune/ldtkgo.(*Property).AsString(...)
/home/scip/go/pkg/mod/github.com/solarlune/[email protected]/ldtkgo.go:54
openquell/systems.(*HudSystem).Draw(0xc0007ce4e0, 0xa4b2f8?)
/home/scip/dev/openquell/systems/hud_system.go:56 +0x384
Although this was entirely my own fault, I think it would be better to get a proper error message here from the library.
Nevertheless - thanks A LOT for this library, already love it!
best,
Tom ("Bad Kraut")
Where is the raylib example? I can't find it
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.