示例#1
0
if maptype is None:
    print 'ERROR: -x or -r required'
    print __doc__%sys.argv[0]
    sys.exit()

filename = '%(x)s-%(e)s-%(r)s'%filename

w = pyglet.window.Window(width=1, height=1, visible=False, alpha_size=8)

mw, mh = size
if maptype == 'recthex':
    m = gen_recthex_map([[{}]*mh]*mw, ch)
elif maptype == 'hex':
    m = gen_hex_map([[{}]*mh]*mw, ch)
else:
    m = gen_rect_map([[{}]*mh]*mw, cw, ch)
pxw = m.pxw
pxh = m.pxh
w.set_size(width=pxw, height=pxh)
w.set_visible()
r = pyglet.ext.scene2d.FlatView(0, 0, pxw, pxh, layers=[m])

class SaveHandler:
    def on_text(self, text):
        if text != 's': return pyglet.window.event.EVENT_UNHANDLED
        image = pyglet.image.BufferImage().get_raw_image()
        fn = filename + '.png'
        n = 1
        while os.path.exists(fn):
            fn = filename + str(n) + '.png'
            n += 1
示例#2
0
文件: genmap.py 项目: pyzh/pyglet
if maptype is None:
    print('ERROR: -x or -r required')
    print(__doc__ % sys.argv[0])
    sys.exit()

filename = '%(x)s-%(e)s-%(r)s' % filename

w = pyglet.window.Window(width=1, height=1, visible=False, alpha_size=8)

mw, mh = size
if maptype == 'recthex':
    m = gen_recthex_map([[dict()] * mh] * mw, ch)
elif maptype == 'hex':
    m = gen_hex_map([[dict()] * mh] * mw, ch)
else:
    m = gen_rect_map([[dict()] * mh] * mw, cw, ch)
pxw = m.pxw
pxh = m.pxh
w.set_size(width=pxw, height=pxh)
w.set_visible()
r = pyglet.ext.scene2d.FlatView(0, 0, pxw, pxh, layers=[m])


class SaveHandler:
    def on_text(self, text):
        if text != 's':
            return pyglet.window.event.EVENT_UNHANDLED
        image = pyglet.image.BufferImage().get_raw_image()
        fn = filename + '.png'
        n = 1
        while os.path.exists(fn):
示例#3
0
文件: genmap.py 项目: bitcraft/pyglet
if maptype is None:
    print('ERROR: -x or -r required')
    print(__doc__ % sys.argv[0])
    sys.exit()

filename = '%(x)s-%(e)s-%(r)s' % filename

w = pyglet.window.Window(width=1, height=1, visible=False, alpha_size=8)

mw, mh = size
if maptype == 'recthex':
    m = gen_recthex_map([[dict()] * mh] * mw, ch)
elif maptype == 'hex':
    m = gen_hex_map([[dict()] * mh] * mw, ch)
else:
    m = gen_rect_map([[dict()] * mh] * mw, cw, ch)
pxw = m.pxw
pxh = m.pxh
w.set_size(width=pxw, height=pxh)
w.set_visible()
r = pyglet.ext.scene2d.FlatView(0, 0, pxw, pxh, layers=[m])


class SaveHandler:

    def on_text(self, text):
        if text != 's':
            return pyglet.window.event.EVENT_UNHANDLED
        image = pyglet.image.BufferImage().get_raw_image()
        fn = filename + '.png'
        n = 1