Added Poly-lines (issue #14) for collision detection...small problem

Avatar

By nikkos 10 Sep 2015 03:34

New member · 7 comments

Added Poly-lines (https://github.com/Tuxemon/Tuxemon/issues/14) for collision detection but I might have broken something else. I tried to change map1.tmx to use the new poly-lines (I only changed the area shown in the example pic posted on the github issue for #14). I only made three changes to the map1.tmx file. One was deleting the old rectangular collision box for the whole ledge, about 5 tiles vertically. The second as adding a single box collision for the box left of the stairs. and then I added a poly-line collision for the ledge (the remaining 4 tiles or so). However, when I go to run tuxemon starting with either bedroom_test.tmx or map1.tmx, it gives me the following error (the game crashes):

...
Tuxemon CLI
Type "help", "copyright", "credits" or "license" for more information.
Tuxemon>> obj is <TiledObject: "Go Downstairs">
obj is ['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'act1', 'act2', 'cond1', 'gid', 'height', 'id', 'name', 'parent', 'parse', 'reserved', 'rotation', 'set_properties', 'type', 'visible', 'width', 'x', 'y']
Traceback (most recent call last):
  File "./tuxemon.py", line 49, in <module>
    main()
  File "/home/dustin/Dropbox/FunProjects/Tuxemon/tuxemon/core/main.py", line 56, in main
    "WORLD": world.World(run_it),
  File "/home/dustin/Dropbox/FunProjects/Tuxemon/tuxemon/core/states/world.py", line 99, in __init__
    self.current_map = map.Map("resources/maps/%s" % prepare.CONFIG.starting_map)
  File "/home/dustin/Dropbox/FunProjects/Tuxemon/tuxemon/core/components/map.py", line 78, in __init__
    self.load(filename)
  File "/home/dustin/Dropbox/FunProjects/Tuxemon/tuxemon/core/components/map.py", line 178, in load
    keys = sorted(obj.properties.keys())
AttributeError: 'TiledObject' object has no attribute 'properties'

I tried to debug it myself, as you can see by the "obj is <TiledObject: "Go Downstairs">" output and the str(dir(obj)) below that. It seems the properties its looking for are not in a properties variable but are just directly in the object (i think act1, act2, and cond1) are the 3 variables that *should* be in the properties variable. Anyway, this is something I haven't dealt with. One thought was that maybe I have a different version of pygame? Just in case, here is my version:

$ apt-show-versions python-pygame
python-pygame:amd64/utopic 1.9.1release+dfsg-10 uptodate

To see the poly-lines working in action, run tuxemon with test_pathfinding.tmx smile
checkout my forked version with poly-lines here: https://github.com/dtdannen/Tuxemon

Avatar

By ShadowApex 10 Sep 2015 05:08

Lead Developer · 374 comments

I cloned your fork and tested it out with no problems. Maybe you are using an old or outdated version of PyTMX or Tiled? PyTMX has, in the past, introduced game breaking changes before. Here are the versions I tested with:

:~$ apt-cache policy python-pygame
python-pygame:
  Installed: 1.9.1release+dfsg-10
  Candidate: 1.9.1release+dfsg-10
  Version table:
 *** 1.9.1release+dfsg-10 0
        500 http://us.archive.ubuntu.com/ubuntu/ vivid/universe amd64 Packages
        100 /var/lib/dpkg/status
:~$ apt-cache policy tiled-daily
tiled-daily:
  Installed: 0+git20150908~15~ubuntu15.04.1
  Candidate: 0+git20150909~15~ubuntu15.04.1
  Version table:
     0+git20150909~15~ubuntu15.04.1 0
        500 http://ppa.launchpad.net/mapeditor.org/tiled/ubuntu/ vivid/main amd64 Packages
 *** 0+git20150908~15~ubuntu15.04.1 0
        100 /var/lib/dpkg/status
:~$ pip show PyTMX
---
Name: PyTMX
Version: 3.20.10