当前位置: 首页>>代码示例>>Python>>正文


Python Engine.load方法代码示例

本文整理汇总了Python中engine.Engine.load方法的典型用法代码示例。如果您正苦于以下问题:Python Engine.load方法的具体用法?Python Engine.load怎么用?Python Engine.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在engine.Engine的用法示例。


在下文中一共展示了Engine.load方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Engine

# 需要导入模块: from engine import Engine [as 别名]
# 或者: from engine.Engine import load [as 别名]
#!/usr/bin/python

from engine import Engine

engine = Engine()

engine.load()
engine.loop()

engine.quit()
quit()


开发者ID:Adriqun,项目名称:C-CPP-SDL2,代码行数:13,代码来源:main.py

示例2: Editor

# 需要导入模块: from engine import Engine [as 别名]
# 或者: from engine.Engine import load [as 别名]
class Editor(object):
    def __init__(self):
        self.engine = Engine(width=1280, height=720, gravity=(0, 0), \
            linear_damping=10.0, angular_damping=10.0, caption='Editor', \
            joint_limit=True, lower_angle=-.2*np.pi, upper_angle=.2*np.pi)

    def load(self, filename='model.json'):
        self.filename = filename
        # load if there's a file
        if self.filename and os.path.isfile(self.filename):
            self.engine.load(self.filename)

    def run(self):
        e = self.engine
        while not e.exited():
            e.window.dispatch_events()
            e.window.clear()
            if e.window.mouse_pressed:
                e.create_mouse_joint()
            else:
                e.destroy_mouse_joint()
            self.handle_keys()
            e.update_mouse_joint()
            e.step_physics(1)
            e.render()
            pyglet.clock.tick()
        e.window.close()

    def handle_keys(self):
        e = self.engine
        if e.selected:
            s = e.selected.userData['size']
            s = (s[0]*e.ppm, s[1]*e.ppm)

            if e.window.pressed(key.RIGHT):
                s = (s[0] + S_STEP, s[1])
            if e.window.pressed(key.LEFT):
                s = (s[0] - S_STEP, s[1])
            if e.window.pressed(key.UP):
                s = (s[0], s[1] + S_STEP)
            if e.window.pressed(key.DOWN):
                s = (s[0], s[1] - S_STEP)
            s = (int(max(S_STEP, s[0])), int(max(S_STEP, s[1])))
            e.set_box(e.selected, s)
        else:
            # joint limit
            if e.window.pressed(key.UP):
                j = e.joint_at(e.window.mouse)
                self.change_joint_limit(j, J_STEP)
            if e.window.pressed(key.DOWN):
                j = e.joint_at(e.window.mouse)
                self.change_joint_limit(j, -J_STEP)

        if e.window.pressed(key.P):
            joint = e.pin_at(e.window.mouse)
        if e.window.pressed(key.S):
            e.save(self.filename)
        if e.window.pressed(key.B):
            e.add_dynamic_body(e.window.mouse, (S_STEP * 3, S_STEP * 2))
        e.window.reset_keys()

    def change_joint_limit(self, j, delta):
        if j:
            lim = j.upperLimit + delta
            lim = max(min(lim, np.pi * 2.0), 0)
            j.upperLimit = lim
            j.lowerLimit = -lim
开发者ID:JonComo,项目名称:stumbly,代码行数:69,代码来源:editor.py


注:本文中的engine.Engine.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。