Exemple #1
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="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
Exemple #2
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
Exemple #3
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
Exemple #4
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