示例#1
0
文件: gui_grid.py 项目: not-na/peng3d
def main(args):
    # Define these as global variables for easier access
    global peng, m_main

    # Create Peng instance
    peng = peng3d.Peng()

    global t, tl
    t, tl = peng.t, peng.tl

    # Create Window with caption
    peng.createWindow(caption="Peng3d Example", resizable=True, vsync=True)
    # Create main GUI Menu and register it immediately
    m_main = peng3d.GUIMenu("main", peng.window, peng)
    peng.window.addMenu(m_main)

    def test_handler(symbol, modifiers, release):
        if release:
            return
        peng.i18n.setLang(langs[(langs.index(peng.i18n.lang) + 1) %
                                len(langs)])

    peng.keybinds.add("f3", "testpy:handler.test", test_handler)

    # Actually creates the GUI
    # In a separate function for clarity and readability
    createGUI()

    # Switch to the main menu and start the main loop
    peng.window.changeMenu("main")
    peng.run()
    return 0
示例#2
0
文件: conftest.py 项目: not-na/peng3d
def peng(request, xdisplay):
    os.environ["DISPLAY"] = xdisplay
    p = peng3d.Peng()

    def fin(p):
        def f():
            try:
                p.window.close()
            except Exception:
                print("pyglet window destroy Exception catched")

        return f

    request.addfinalizer(fin(p))
    return p
示例#3
0
def main(args):
    # Define these as global variables for easier access
    global peng, m_main

    # Create Peng instance
    peng = peng3d.Peng()

    global t, tl
    t, tl = peng.t, peng.tl

    # Create Window with caption
    peng.createWindow(caption_t="i18n:common.window.caption",
                      resizable=True,
                      vsync=True)
    # Create main GUI Menu and register it immediately
    m_main = peng3d.GUIMenu("main", peng.window, peng)
    peng.window.addMenu(m_main)

    def test_handler(symbol, modifiers, release):
        if release:
            return
        peng.i18n.setLang(langs[(langs.index(peng.i18n.lang) + 1) %
                                len(langs)])

    peng.keybinds.add("f3", "testpy:handler.test", test_handler)

    # Actually creates the GUI
    # In a separate function for clarity and readability
    createGUI()

    for cname, cdat in categories.items():
        sma_bar.addCategory(cname, cdat[0], cdat[1], cdat[2])

    def update(dt=None):
        for cname, cdat in categories.items():
            nmin, n, nmax = sma_bar[cname]
            n += cdat[3]
            if n >= nmax:
                print(tl("i18n:gui_adv.wraparound") % cname)
            n %= nmax
            sma_bar.updateCategory(cname, n=n)

    pyglet.clock.schedule_interval(update, 1. / 60)

    # Switch to the main menu and start the main loop
    peng.window.changeMenu("main")
    peng.run()
    return 0
示例#4
0
def main(args):
    # Define these as global variables for easier access
    global peng, m_main
    
    # Create Peng instance
    peng = peng3d.Peng()
    # Create Window with caption
    peng.createWindow(caption="Peng3d Example",resizable=True,vsync=True)
    # Create main GUI Menu and register it immediately
    m_main = peng3d.GUIMenu("main",peng.window,peng)
    peng.window.addMenu(m_main)
    
    # Actually creates the GUI
    # In a separate function for clarity and readability
    createGUI()
    
    # Switch to the main menu and start the main loop
    peng.window.changeMenu("main")
    peng.run()
    return 0
示例#5
0
def main(args):
    global peng,esc_toggle
    # Peng engine instance creation and creating the window
    peng = peng3d.Peng()
    peng.createWindow(caption_t="i18n:gui_basic.caption",resizable=True,vsync=True)
    #peng.window.toggle_exclusivity()
    # Keybinds
    def esc_toggle(symbol,modifiers,release):
        if release:
            return
        peng.window.toggle_exclusivity()
        player.controlleroptions["enabled"] = peng.window.exclusive
        if not peng.window.exclusive:
            gamel.changeSubMenu("pause")
        else:
            gamel.changeSubMenu("hud")
    peng.keybinds.add("escape","testpy:handler.esctoggle",esc_toggle)
    def test_handler(symbol,modifiers,release):
        if release:
            return
        #peng.keybinds.changeKeybind("peng3d:actor.player.controls.forward","space")
        print("pos,labelpos")
        print(playbtn.pos)
        print(playbtn._label.x,playbtn._label.y)
        playbtn._label._update()
    peng.keybinds.add("f3","testpy:handler.test",test_handler)
    # Fog and clear color config
    peng.cfg["graphics.clearColor"]=[0.5,0.69,1.0,1.0]
    peng.cfg["graphics.fogSettings"]["enable"]=True
    peng.cfg["graphics.fogSettings"]["start"]=4
    peng.cfg["graphics.fogSettings"]["end"]=8
    # Creates world/cam/view/player
    world = peng3d.StaticWorld(peng,TERRAIN,COLORS)
    #player = peng3d.actor.player.FirstPersonPlayer(peng,world)
    player = peng3d.actor.player.BasicPlayer(peng,world)
    # Player controllers
    player.addController(peng3d.actor.player.FourDirectionalMoveController(player))
    player.addController(peng3d.actor.player.EgoMouseRotationalController(player))
    player.addController(peng3d.actor.player.BasicFlightController(player))
    # Player view/camera
    world.addActor(player)
    c = peng3d.CameraActorFollower(world,"cam1",player)
    world.addCamera(c)
    v = peng3d.WorldView(world,"view1","cam1")
    world.addView(v)
    # Creates menu/layer
    mgame = peng3d.Menu("game",peng.window,peng)
    mgame.addWorld(world)
    peng.window.addMenu(mgame)
    l = peng3d.LayerWorld(mgame,peng.window,peng,world,"view1")
    mgame.addLayer(l)
    # Create Main Menu
    mmain = peng3d.GUIMenu("main",peng.window,peng)
    peng.window.addMenu(mmain)
    createGUI(mmain,mgame)
    # Switch to the main menu
    peng.window.changeMenu("main")
    # Done!
    if CONSOLE:
        # Starts a console in seperate Thread, allows interactive debugging and testing stuff easily
        t = threading.Thread(target=code.interact,name="REPL Thread",kwargs={"local":locals()})
        t.daemon = True
        t.start()
    # Starts the main loop
    peng.run()
    return 0
示例#6
0
文件: headless.py 项目: not-na/peng3d
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#  test_headless.py
#
#  Copyright 2016 notna <*****@*****.**>
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#  MA 02110-1301, USA.
#
#

import peng3d

p = peng3d.Peng()
示例#7
0
def test_peng_config():
    p = peng3d.Peng({"test.key1": "foo"})
    assert p.cfg["test.key1"] == "foo"
示例#8
0
def test_peng_create():
    p = peng3d.Peng()
    assert p.window is None
    assert isinstance(p, peng3d.peng.Peng) and isinstance(p, peng3d.Peng)
    assert peng3d.Peng is peng3d.peng.Peng