Created
October 31, 2015 11:51
-
-
Save stamaniorec/12f1e3dc48bd8da5bbfa to your computer and use it in GitHub Desktop.
#pygame mouse event handling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| while is_running: | |
| for event in pygame.event.get(): | |
| if event.type == MOUSEBUTTONDOWN: | |
| if event.button == 1: | |
| print("Left button") | |
| elif event.button == 3: | |
| print("Right button") | |
| # 4, 5, 6 are scroll events, not sure about the details | |
| elif event.type == MOUSEBUTTONUP: | |
| if event.button == 1: | |
| print("Released left button") | |
| elif event.button == 3: | |
| print("Released right button") | |
| else: | |
| pass # scroll events | |
| elif event.type == pygame.MOUSEMOTION: | |
| mouse_x = event.pos[0] | |
| mouse_y = event.pos[1] | |
| print("%s %s" % (mouse_x, mouse_y)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment