-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpygame_joystick.py
32 lines (25 loc) · 911 Bytes
/
pygame_joystick.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Example file showing a basic pygame "game loop"
import pygame
# pygame setup
pygame.init()
# screen = pygame.display.set_mode((1280, 720))
clock = pygame.time.Clock()
running = True
pygame.joystick.init()
joysticks = [pygame.joystick.Joystick(x) for x in range(pygame.joystick.get_count())]
print(f'joysticks:{joysticks}')
while running:
# poll for events
# pygame.QUIT event means the user clicked X to close your window
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.JOYBUTTONDOWN and joysticks[0].get_button(0):
print(f'AAAAA')
# fill the screen with a color to wipe away anything from last frame
# screen.fill("purple")
# RENDER YOUR GAME HERE
# flip() the display to put your work on screen
# pygame.display.flip()
clock.tick(60) # limits FPS to 60
pygame.quit()