Giter Site home page Giter Site logo

ldtkgo's People

Contributors

eliasdaler avatar quasilyte avatar solarlune avatar soockee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ldtkgo's Issues

Empty Level.Layers when opening a 1.5.3 LDtk project

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):

test.zip

entity.TileRect points to wrong tileset region when using Tile Property

Ok, so I have a tile setup which looks like this:

ldtk-entity-def

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:

samesprites

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   

This is the tileset:
tileset

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:

display

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.

nil pointer dereference when calling PropertyByIdentifier with non-existing key

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")

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.