Beispiel #1
0
 def update(self):
     self.playButton.x += (self.playButton.tx - self.playButton.x)/10
     if (abs(self.playButton.x - eventManager.mouse.position.x)<self.playButton.width/2):
         self.playButton.y += (self.playButton.ty + (self.playButton.ty - eventManager.mouse.position.y)**3/80000.0 - self.playButton.y)/10
         self.optionsButton.y += (self.optionsButton.ty + (self.optionsButton.ty - eventManager.mouse.position.y)**3/80000.0 - self.optionsButton.y)/10
     else:
         self.playButton.y += (self.playButton.ty - self.playButton.y)/10
         self.optionsButton.y += (self.optionsButton.ty - self.optionsButton.y)/10
     self.optionsButton.x += (self.optionsButton.tx - self.optionsButton.x)/10
     #check if play button pressed
     for event in eventManager.lastEvents:
         if (event.type == "mousedown" and event.value == 0):
             if (eventManager.mouse.position.withinRect(self.playButton,self.playButton.width,self.playButton.height)):
                 frameController.add("game",GameFrame(GameData()))
                 frameController.rem("main")
                 self.finished = 1
Beispiel #2
0
def on_mouse_press(x,y,button,modifiers):
    if (button == pyglet.window.mouse.LEFT):
        eventManager.mouse.down = 1
        eventManager.lastEvents.append(eventManager.Event("mousedown",0))
    elif (button == pyglet.window.mouse.RIGHT):
        eventManager.mouse.rightDown = 1
        eventManager.lastEvents.append(eventManager.Event("mousedown",1))
    else:
        eventManager.mouse.middleDown = 1
        eventManager.lastEvents.append(eventManager.Event("mousedown",2))
@window.event
def on_mouse_release(x,y,button,modifiers):
    if (button == pyglet.window.mouse.LEFT):
        eventManager.mouse.down = 0
        eventManager.lastEvents.append(eventManager.Event("mouseup",0))
    elif (button == pyglet.window.mouse.RIGHT):
        eventManager.mouse.rightDown = 0
        eventManager.lastEvents.append(eventManager.Event("mouseup",1))
    else:
        eventManager.mouse.middleDown = 0
        eventManager.lastEvents.append(eventManager.Event("mouseup",2))
#This is called FRAME_RATE times a second to update the frames (not render them)
def update(dt):
    frameController.update()
    eventManager.lastEvents = []
pyglet.clock.schedule_interval(update, setting.FRAME_RATE)

#Change this to test different frames
frameController.add("main",frames.mainMenuFrame.MainMenuFrame())

pyglet.app.run()