예제 #1
0
파일: main.py 프로젝트: szx/YAPGU
def start(argv):
    graphics.assetDirectory('assets')
    sprite = graphics.Sprite("sprite.png", Vector2D(100.0,100.0), frames=9)
    button = GUI.Button("button.png", Vector2D(200.0,100.0))
    def drawFunc():
        sprite.draw()
        button.draw()
        graphics.drawText("Works!", Vector2D(80.0,550.0), Color(0,0,255))
    graphics.init(800, 600, drawFunc)
    inputf.init()
    GUI.init()
    
    def movementMicrothread():
        while True:
            if inputf.keyboard[inputf.key.UP]:
                sprite.position.y += 10 * logic.delta()
            if inputf.mouse.left:
                sprite.position.x += 10 * logic.delta()
            #else:
            #    sprite.position.x -= 10 * logic.delta()
            if inputf.mouse.inRect(sprite):
                sprite.position.y -= 10 * logic.delta()
            microthreads.schedule()
    microthreads.microthread(movementMicrothread)
    
    logic.start()
    
예제 #2
0
파일: graphics.py 프로젝트: szx/YAPGU
def init(width, height, drawingFunc, vSync = False):
    """
    Initializes graphics - main window, audio etc.
    
    General usage:
        # Loading all necessary assets etc.
        ...
        sprite = Sprite(...)
        ...
        # Defining drawing function.
        def drawFunc():
            sprite.draw()
        graphics.init(800, 600, drawFunc) #Initializing with 800x600 window.
    
    Notes:
        - Initialize pyglet after loading all assets. (szx)
    
    Maintainers: szx
    Last update date: 20.01.2013 
    """
    global _window
    global _label
    # Speed hack.
    pyglet.options['debug_gl'] = False
    # Audio configuration.
    pyglet.options['audio'] = ('directsound', 'openal', 'silent')
    # Initializing text label.
    _label = pyglet.text.Label('',
                               font_name='Times New Roman',
                               font_size=36)
    # Initializing Pyglet's main window.
    _window = pyglet.window.Window(800,600, vsync=vSync)
    # Making SpriteSupermeCommander microthread.
    microthread(SpriteSupermeCommander)

    #Pyglet's main rendering function.
    @_window.event
    def on_draw():
        _window.clear()
        drawingFunc()
예제 #3
0
파일: unittests.py 프로젝트: szx/YAPGU
 def __init__(self, amount, message="PING"):
     self.amount = amount  # Loop counter.
     self.message = message
     microthread(self.update)