Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problems with pytmx
#13
(Jan-03-2020, 07:13 PM)michael1789 Wrote: try replacing your code with what I have.
class TileMap:
    def __init__(self, filename):
        tm = load_pygame(filename, pixelalpha=True)
        self.width = tm.width * tm.tilewidth
        self.height = tm.height * tm.tilewidth
        self.tmxdata = tm
They are very different.

Where you define "tm" I think you need "()" at the end.

I replayed it with your code and now I have this error:


Traceback (most recent call last):
  File "/Users/.../Desktop/MyRPG/main.py", line 5171, in <module>
    g = Game()
  File "/Users/.../Desktop/MyRPG/main.py", line 15, in __init__
    self.load_data()
  File "/Users/.../Desktop/MyRPG/main.py", line 61, in load_data
    self.map = TiledMap(path.join(map_folder, 'map1.tmx'))
  File "/Users/.../Desktop/MyRPG/tilemap.py", line 29, in __init__
    tm = load_pygame(filename, pixelalpha=True)
NameError: name 'load_pygame' is not defined
It says that load_pygame is not defined. You said, that at the tm thing I'd need a () at the end. But you don't have that either. So I tried it also this way:

def __init__(self, filename):
        tm = pytmx.util_pygame.load_pygame()
        #tm = load_pygame(filename, pixelalpha=True)
        self.width = tm.width * tm.tilewidth
        self.height = tm.height * tm.tilewidth
        self.tmxdata = tm
There I am getting a different error, which is:

Traceback (most recent call last):
  File "/Users/.../Desktop/MyRPG/main.py", line 5, in <module>
    from sprites import *
  File "/Users/.../Desktop/MyRPG/sprites.py", line 4, in <module>
    from tilemap import collide_hit_rect
  File "/Users/.../Desktop/MyRPG/tilemap.py", line 28
    def __init__(self, filename):
                                ^
IndentationError: unindent does not match any outer indentation level
I checked that it is intentioned, but although I'm getting this error above.
Reply


Messages In This Thread
Problems with pytmx - by Piethon - Dec-24-2019, 11:27 AM
RE: Problems with pytmx - by nilamo - Dec-27-2019, 05:01 PM
RE: Problems with pytmx - by Piethon - Dec-29-2019, 08:35 AM
RE: Problems with pytmx - by metulburr - Dec-29-2019, 01:20 PM
RE: Problems with pytmx - by michael1789 - Dec-29-2019, 06:25 PM
RE: Problems with pytmx - by Piethon - Jan-02-2020, 08:47 AM
RE: Problems with pytmx - by metulburr - Jan-02-2020, 12:20 PM
RE: Problems with pytmx - by michael1789 - Jan-02-2020, 03:14 PM
RE: Problems with pytmx - by Piethon - Jan-03-2020, 11:06 AM
RE: Problems with pytmx - by michael1789 - Jan-03-2020, 01:43 PM
RE: Problems with pytmx - by Piethon - Jan-03-2020, 05:55 PM
RE: Problems with pytmx - by michael1789 - Jan-03-2020, 07:13 PM
RE: Problems with pytmx - by Piethon - Jan-04-2020, 08:58 AM
RE: Problems with pytmx - by michael1789 - Jan-04-2020, 06:09 PM
RE: Problems with pytmx - by metulburr - Jan-04-2020, 03:37 PM
RE: Problems with pytmx - by Piethon - Jan-05-2020, 10:44 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to display isometric maps with pytmx? Piethon 18 10,208 Feb-19-2020, 04:33 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020