Ejemplo n.º 1
0
 def add_event(cls, event):
     """
     Add a single pygame.event to the dictionary.
     """
     if event.type == KEYDOWN:
         Input.events.update({event.key: [event, Input.DOWN]})
         Input.pressed.add(event.key)
     elif event.type == KEYUP:
         Input.events.update({event.key: [event, Input.UP]})
     elif event.type == MOUSEBUTTONDOWN:
         d = {'pos': descale_point(event.pos), 'button': event.button}
         event = pygame.event.Event(MOUSEBUTTONDOWN, d)
         Input.events.update({Input.butt[event.button]: [event, Input.DOWN]})
         Input.pressed.add(Input.butt[event.button])
     elif event.type == MOUSEBUTTONUP:
         d = {'pos': descale_point(event.pos), 'button': event.button}
         event = pygame.event.Event(MOUSEBUTTONUP, d)
         Input.events.update({Input.butt[event.button]: [event, Input.UP]})
     elif event.type == MOUSEMOTION:
         d = {'pos': descale_point(event.pos), 'buttons': event.buttons,
              'rel': descale_point(event.rel)}
         event = pygame.event.Event(MOUSEMOTION, d)
         Input.events.update({MOUSEMOTION: [event, Input.MOTION]})
     elif event.type == pygame.QUIT:
         Input.events.update({'QUIT': [event, True]}) # Fix by Gautham (comment on the blog)
Ejemplo n.º 2
0
 def update_mouse(cls, buttons = (0,0,0), pos = (0,0)):
     """
     Updates the mouse postion and the three main buttons state.
     pygame.mouse.get_pos() and pygame.mouse.get_pressed()
     """
     Input.mouse_pos = descale_point(pos)
     Input.button_state = buttons
Ejemplo n.º 3
0
 def update_mouse(cls, buttons=(0, 0, 0), pos=(0, 0)):
     """
     Updates the mouse postion and the three main buttons state.
     pygame.mouse.get_pos() and pygame.mouse.get_pressed()
     """
     Input.mouse_pos = descale_point(pos)
     Input.button_state = buttons
Ejemplo n.º 4
0
 def add_event(cls, event):
     """
     Add a single pygame.event to the dictionary.
     """
     if event.type == KEYDOWN:
         Input.events.update({event.key: [event, Input.DOWN]})
         Input.pressed.add(event.key)
     elif event.type == KEYUP:
         Input.events.update({event.key: [event, Input.UP]})
     elif event.type == MOUSEBUTTONDOWN:
         d = {"pos": descale_point(event.pos), "button": event.button}
         event = pygame.event.Event(MOUSEBUTTONDOWN, d)
         Input.events.update({Input.butt[event.button]: [event, Input.DOWN]})
         Input.pressed.add(Input.butt[event.button])
     elif event.type == MOUSEBUTTONUP:
         d = {"pos": descale_point(event.pos), "button": event.button}
         event = pygame.event.Event(MOUSEBUTTONUP, d)
         Input.events.update({Input.butt[event.button]: [event, Input.UP]})
     elif event.type == MOUSEMOTION:
         d = {"pos": descale_point(event.pos), "buttons": event.buttons, "rel": descale_point(event.rel)}
         event = pygame.event.Event(MOUSEMOTION, d)
         Input.events.update({MOUSEMOTION: [event, Input.MOTION]})
     elif event.type == pygame.QUIT:
         Input.events.update({"QUIT": [event, True]})  # Fix by Gautham (comment on the blog)