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

problem occured with get_tile_image_by_gid() #195

Open
Ogerjut opened this issue Nov 17, 2024 · 0 comments
Open

problem occured with get_tile_image_by_gid() #195

Ogerjut opened this issue Nov 17, 2024 · 0 comments

Comments

@Ogerjut
Copy link

Ogerjut commented Nov 17, 2024

Hello everyone,
I'm still rookie in programmation, but i decided to deeply understand pytmx for a personnal project.

self.map is my TileMap, i'm actually trying to get tiles's images of my map in the code in this way :

for gid in self.map.tiledgidmap.values() :
            print(gid) #work well, i got all the gid like in the .tmx file
            image = self.map.get_tile_image_by_gid(gid) #here the error 
            print(f"gid {gid} : {image}")

but i got an error with the method get_tile_image_by_gid() that i still dont understand after several hour of debugging ^^'
Actually I did all the checking chatGPT advice me and all "should" be working

Traceback (most recent call last):
File "C:\Users\AppData\Local\Programs\Python\Python311\Lib\site-packages\pytmx\pytmx.py", line 717, in get_tile_image_by_gid
return self.images[gid]
~~~~~~~~~~~^^^^^
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\Users\rvvr4\OneDrive\Bureau\Programmation\pygame\towerdef_tiles\main.py", line 45, in
app = App()
^^^^^
File "c:\Users\pygame\game2\main.py", line 16, in init
"nature": Tile(self.screen, "tile_1.tmx", x=0),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\pygame\game2\tile.py", line 36, in init
image = self.map.get_tile_image_by_gid(gid)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\AppData\Local\Programs\Python\Python311\Lib\site-packages\pytmx\pytmx.py", line 724, in get_tile_image_by_gid
logger.debug(msg.format(gid))
^^^^^^^^^^^^^^^
IndexError: Replacement index 1 out of range for positional args tuple

here the code => files in good dir, class Tile and tile.tmx (forget line 37,38)
screen of issue

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

No branches or pull requests

1 participant