Python& Pyglet Minecraft示例代码错误

时间:2013-11-20 22:26:09

标签: python-3.x python-3.3 pyglet

所以我在我的Mac上构建了Pyglet,并尝试将它与Minecraft(Python)演示代码一起使用,但我得到了这个错误,我意识到它源于Pyglet本身。这是完整的错误:

Traceback (most recent call last):
  File "/Users/Noah/Desktop/PyCraft/main.py", line 892, in <module>
    main()
  File "/Users/Noah/Desktop/PyCraft/main.py", line 890, in main
    pyglet.app.run()
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyglet/app/__init__.py", line 123, in run
    event_loop.run()
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyglet/app/base.py", line 127, in run
    self._legacy_setup()
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyglet/app/base.py", line 218, in _legacy_setup
    window.dispatch_pending_events()
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyglet/window/cocoa/__init__.py", line 324, in dispatch_pending_events
    EventDispatcher.dispatch_event(self, *event)
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyglet/event.py", line 369, in dispatch_event
    event_type, args, getattr(self, event_type))
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyglet/event.py", line 365, in dispatch_event
    if getattr(self, event_type)(*args):
  File "/Users/Noah/Desktop/PyCraft/main.py", line 767, in on_resize
    ('v2i', (x - n, y, x + n, y, x, y - n, x, y + n))
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyglet/graphics/__init__.py", line 289, in vertex_list
    return _get_default_batch().add(count, 0, None, *data)
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyglet/graphics/__init__.py", line 359, in add
    vlist._set_attribute_data(i, array)
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyglet/graphics/vertexdomain.py", line 440, in _set_attribute_data
    region.array[:] = data
TypeError: int expected instead of float

任何输入都会有所帮助。谢谢!

3 个答案:

答案 0 :(得分:1)

  File "/Users/Noah/Desktop/PyCraft/main.py", line 767, in on_resize
    ('v2i', (x - n, y, x + n, y, x, y - n, x, y + n))

def on_resize(self, width, height):
        """ Called when the window is resized to a new `width` and `height`.

        """
        # label
        self.label.y = height - 10
        # reticle
        if self.reticle:
            self.reticle.delete()
        x, y = self.width / 2, self.height / 2

v2i,我代表整数,但你正在传递花车。将最后一行更改为

        x, y = self.width // 2, self.height // 2

答案 1 :(得分:0)

基本类型错误是您尝试将数字(IE 1)设置为浮点数(IE 1.1)。 将代码放在粘贴bin上会非常有用。

谢谢,Jonathan

答案 2 :(得分:0)

在我看来,另一个问题在于您使用的是Python 3.3。 Pyglet支持2.x。