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
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
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
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
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
#!/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()
def test_peng_config(): p = peng3d.Peng({"test.key1": "foo"}) assert p.cfg["test.key1"] == "foo"
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