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 33 34 35 36 37 38 39 40 41 42 43 44 45
| import pygame
pygame.init()
game_display = pygame.display.set_mode((500,500))
fenetre = pygame.display.set_mode((500,500))
son1 = pygame.mixer.Sound("316913__jaz-the-man-2__si.wav")
son2 = pygame.mixer.Sound("60141__uzerx__guitar-noise-2.wav")
son3 = pygame.mixer.Sound(b"441057__jnvrbs__click.wav")
son4 = pygame.mixer.Sound(b"112568__juskiddink__piano-f-minor-chord-5th-octave.wav")
son5 = pygame.mixer.Sound(b"345272__soneproject__ecofuture1.wav")
pygame.mouse.set_visible(False)
pygame.event.set_grab(True) # confines the mouse cursor to the window
exit = False
while (not exit):
pygame.mouse.set_pos(0, 0)
mouse_move = (0,0)
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit = True
if event.type == pygame.MOUSEMOTION:
mouse_move = event.rel
if mouse_move <= (5, 5) + (5, -5):
son1.play()
if mouse_move >= (-5, 5) + (-5, -5):
son1.play()
if mouse_move >= (5, 5) + (5, -5):
son1.stop()
if mouse_move <= (-5, 5) + (-5, -5):
son1.stop()
if mouse_move >= (11 , 50):
son2.play()
if mouse_move <= (-50, 10):
son3.play()
if mouse_move >= (10, 50):
son4.play()
if mouse_move <= (-10, 50):
son5.play()
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
exit = True
if mouse_move != (0,0):
print(mouse_move)
pygame.quit() |
Partager