-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrols.py
30 lines (26 loc) · 1.07 KB
/
controls.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
import pygame
from pygame.locals import *
FPS = 60
def ShowControls(clock, screen, joysticks):
background = pygame.image.load("res/img/controls.png")
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT: # Handle window exit gracefully
running = False
return 0
if event.type == pygame.KEYDOWN:
running = False
return 1
if event.type == JOYBUTTONDOWN:
running = False
return 1
if event.type == JOYDEVICEADDED:
joysticks = [pygame.joystick.Joystick(i) for i in range(pygame.joystick.get_count())]
for joystick in joysticks:
print(joystick.get_name())
if event.type == JOYDEVICEREMOVED:
joysticks = [pygame.joystick.Joystick(i) for i in range(pygame.joystick.get_count())]
screen.blit(background, background.get_rect())
pygame.display.flip()
clock.tick(FPS)