Skip to content
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

Big problem with ID sprites #4018

Open
ManPython opened this issue Jul 27, 2024 · 13 comments
Open

Big problem with ID sprites #4018

ManPython opened this issue Jul 27, 2024 · 13 comments
Labels
bug Broken behavior.

Comments

@ManPython
Copy link

ManPython commented Jul 27, 2024

Describe the bug
The dock property for sprite_2 sprite_3 showing tile ID = 2, 3 4 in case in file is 484, 486

To Reproduce

Expected behavior
This same ID in dock widget like file .tmx

Media
not have time for this

Specifications:

  • OS: [e.g. Windows 10]
  • Tiled Version: 1.11
@ManPython ManPython added the bug Broken behavior. label Jul 27, 2024
@eishiya
Copy link
Contributor

eishiya commented Jul 27, 2024

It sounds like you might be confusing the global tile IDs (GIDs) in the maps with the local tile IDs in tilesets. Since a map may contain multiple tilesets, it can't store the tile IDs directly, it has to distinguish between tiles from different tilesets that may have the same IDs. GIDs are a way to re-number tiles from different tilesets and thus remain unambiguous. More info in the docs: https://doc.mapeditor.org/en/stable/reference/global-tile-ids/

@ManPython
Copy link
Author

Then in property dock window we need both ID and GID coz hard to operate with of ID should be for collisions etc cases with algo game.

@ManPython
Copy link
Author

ManPython commented Jul 27, 2024

Strange.. I did not know that can be different ID.. in .tmx file is not separated.. but is dissonance when working with map and have some sprites to touch and identify for code.. I see repeatable ID on .tmx files but ID on file is different from GUI dock.

@eishiya
Copy link
Contributor

eishiya commented Jul 27, 2024

GIDs are a format-specific detail, they do not exist until you write the map out as a file, and different file formats may use different ways to disambiguate tilesets, not all of them use GIDs.

You should NOT be using GIDs as part of your game logic! They may be inconsistent between maps (if maps e.g. use different tilesets, or use the same tilesets in a different order), and they are a file format implementation detail. You should use data assigned to the actual tiles instead. At best, you can use the tile IDs, but ideally you should be using custom properties on the tiles.

You should not need to even look at tile IDs generally, Tiled provides much better tools for things like matching in-game data to specific tiles (or layers, or objects, or maps...).

@ManPython
Copy link
Author

Don't care.. need in app see the ID as .tmx file have.. coz nothing to do.. but bad case is to searching ID for sprite in .tmx file to recognize and control by code.

@ManPython
Copy link
Author

ManPython commented Jul 27, 2024

For my dock sprite ID is 5 and here in file 486.. etc.. then workflow is bad - and when 2 or more layers, worst.
ids

@ManPython
Copy link
Author

Looks problem is more advanced or bug..
When adding more sprite and exporting to .tsx then no any ID for other sprites to identify, just metatiles have as first.
Soo..in whole app is no option to find 484 that game should recognize and checking to control in some algo relations.

@ManPython
Copy link
Author

Finally comment.. there is no option to see GID in GUI app, only when preview .tmx file in some other editor like notepad.. this is bad case.

@eishiya
Copy link
Contributor

eishiya commented Aug 7, 2024

As I wrote before, GIDs are a file format implementation detail, not all map formats use them. So, they simply "don't exist" to be displayed in the GUI, they're only generated as needed if/when you write to a file format that uses them. Just like image editors don't let you view/edit the PNG data blocks directly, Tiled doesn't let you view/edit the GIDs - because they're not actually the map data, just a way to represent it in a text format. That you're making active use of them in your game beyond merely using them to reconstitute the map data is an unintended use case that is not likely to become supported.

@ManPython
Copy link
Author

Don't know what You trying explain.. and thats mind GIDs ID should be as "unknow" in GUI and not used in development? Each sprite added to map on second layer as coins for examples are far from ID.. and to discover colision must operate this ID from .tmx map..
Your explanation around PNG etc. images is far.. as eg. "Paint not offering see exif or edit", but here is example about basic function like identify pixels, where pixels on maps are ID or GIDs..

Then.. try to load to python .tmx file with pytmx libarary to operate collisions.. or something.
I still must know with sprite ID on map layer I should pack in code and special actions.. and I can't predict each new added sprite..

Tiled doesn't let you view/edit the GIDs - because they're not actually the map data, just a way to represent it in a text format.

What a stupid explanation.. here.. GIDs are in tmx file as image I added 484.. it is a tile on layer.
You probably missing facts that additional tilesets as sprites (characters, eg. coins, ) not terrain objects are shifted on some array of ID, then ID on maps and .tmx and GUI is this same but next tileset as sprite are not for identify, then.. search on .tmx layer with number app set on layer array..

Are you developing games with this app and gui? How you recognizing tile for collision like coins?

@eishiya
Copy link
Contributor

eishiya commented Aug 7, 2024

Yes, I am developing games with Tiled. I identify tiles by the method described on the GID documentation page I linked earlier - the GID tells me which tileset the tile is from, and which tile in that tileset it is. The GIDs are only relevant when reading the map in my game, at which point I create the data as used by my game directly (collision representation, lists of collectible items, drawables, etc). In my game I don't need to keep tile identifiers around after that, but if I did, I would use tile pointers, not GIDs, since a tile pointer is unique to the tile, while a single tile may have as many different GIDs as there are maps.

I don't understand what you're doing in your game. Either you're overcomplicating things, or you didn't read the documentation page I linked and are misunderstanding the function of the GIDs.

@ManPython
Copy link
Author

ManPython commented Aug 8, 2024

What is tile pointer for you? Looks like not GID?

But how you counting or mapping this IDs per sprite without checking .tmx file? The case is that I don't want to verify nothing in .tmx files coz why? But now must due GUI.
I made example with tiles 64x64px where are just 4 tiles.
I opened 128x128.png for this and named test1 then opened again this same file but name 128x128 in GUI then position of tiles in GUI was replaced to first in GUI, repeated this step and have two this same 128x128 . I was sure that firstgi=1 and firstgid=2 as next but is 5 next this same is 9.

Then if you developing games, how you doing identification for .png files if in developing process eg. adding more tiles, operating names as workflow? You trying manage names to be sure it is next after current tabs?

<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.11.0" orientation="orthogonal" renderorder="right-down" width="30" height="20" tilewidth="64" tileheight="64" infinite="0" nextlayerid="2" nextobjectid="1">
 <tileset firstgid="1" name="test" tilewidth="64" tileheight="64" tilecount="4" columns="2">
  <image source="../../../Game — draft/BG/128x128.png" trans="000000" width="128" height="128"/>
 </tileset>
 <tileset firstgid="5" name="128x128" tilewidth="64" tileheight="64" tilecount="4" columns="2">
  <image source="../../../Game — draft/BG/128x128.png" trans="000000" width="128" height="128"/>
 </tileset>
 <tileset firstgid="9" name="128x128" tilewidth="64" tileheight="64" tilecount="4" columns="2">
  <image source="../../../Game — draft/BG/128x128.png" trans="000000" width="128" height="128"/>
 </tileset>
 <layer id="1" name="Tile Layer 1" width="30" height="20">
  <data encoding="csv">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
9,10,11,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
5,6,7,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</data>
 </layer>
</map>

Also is possible in GUI replace tile positions accidentally or as dev want when edit:

<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.11.0" orientation="orthogonal" renderorder="right-down" width="30" height="20" tilewidth="64" tileheight="64" infinite="0" nextlayerid="2" nextobjectid="1">
 <tileset firstgid="1" name="test" tilewidth="64" tileheight="64" tilecount="4" columns="2">
  <image source="../../../Game — draft/BG/128x128.png" trans="000000" width="128" height="128"/>
 </tileset>
 <tileset firstgid="5" name="128x128x2" tilewidth="64" tileheight="64" tilecount="4" columns="2">
  <grid orientation="orthogonal" width="128" height="128"/>
  <image source="../../../Game — draft/BG/128x128.png" trans="000000" width="128" height="128"/>
  <tile id="1"/>
  <tile id="2"/>
  <tile id="3"/>
  <tile id="0"/>
 </tileset>
 <tileset firstgid="9" name="128x128" tilewidth="64" tileheight="64" tilecount="4" columns="2">
  <image source="../../../Game — draft/BG/128x128.png" trans="000000" width="128" height="128"/>
 </tileset>
 <tileset firstgid="13" name="test2" tilewidth="64" tileheight="64" tilecount="4" columns="2">
  <image source="../../../Game — draft/BG/128x128.png" trans="000000" width="128" height="128"/>
 </tileset>
 <layer id="1" name="Tile Layer 1" width="30" height="20">
  <data encoding="csv">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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case, adding next sprites and tiles but not 64x64 but 32x32.. so by this counting it's not so clear as + next similar size array for this..
Then do this twice, use in code counted id, and delete 2 last sprites and add next 2 as other.. coz developing.. again replace code (bad workflow).
From my perspective in some cases counter should not be reset to continue ID.

  • edit: class vs type need to be resolved

@ManPython
Copy link
Author

ManPython commented Aug 21, 2024

From my side and experience exist bug.
If I have 1st tileset as 1st tile is blue like sky, 2nd itile is green as ground, then 0-1 as passable for blue and 2 for collision.
Exist other collision type with ID 2-10.
But when operating layers like option to override view where 1st layer is painted as all for blue, then 2nd layer as some green terrain. Or other operations are done then backing to the basic concept as all main view (sky + ground on one layer), then GID is changed from 1 - sky, 2 ground where 537 - sky, 538 ground.

2nd tilesets are characters.

Due changes around GID as not rational case here, then if many maps as .tmx files is impossible to easy mange tiles as good workflow without hard job.
Simple.. for many .tmx can be this same metatile (sky+ground) and sprite, just other painted edited. Then if this same GID for each .tmx file the in game logic all is easy.. 1- sky, 2 ground //NOT NEED TO SET class/type for tile as "sky" or "ground" ("pointers" vars??) even integer is faster and maybe class/type = 0/1 is possible to write, but why do this for constant logic?

GID not respecting "FIFO" here, by this whole array is always broken in case basic map image tiles are still this same.
Patterning tiles is impossible by current state in easy way in similar maps. To much repeatable job (due each .tmx need class/type).

Note case.. that without Tiled Editor for gaming was excel/csv used ;]
But not referring to workflow, but logic for map cells used in game.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Broken behavior.
Projects
None yet
Development

No branches or pull requests

2 participants