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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
#
# CiXOs FIA Proyecto
# Evento SPRINT 23 de Abril!
#
import pygame
from pygame.locals import *
from pygame.sprite import Sprite
from cuadrado import *
pygame.mixer.init()
pygame.font.init()
salir = False
screen = pygame.display.set_mode((640,480))
pygame.display.set_caption("^__^")
fondo = pygame.image.load("fondo.png").convert_alpha()
pygame.mouse.set_visible(True)
sprites = pygame.sprite.OrderedUpdates()
cuadrado = pygame.sprite.Group()
rectangulo = pygame.sprite.Group()
triangulo = pygame.sprite.Group()
circulo = pygame.sprite.Group()
esfera = pygame.sprite.Group()
cubo = pygame.sprite.Group()
cuadrado.add([Cuadrado(102, 340)])
rectangulo.add([Rectangulo(397, 340)])
triangulo.add([Triangulo(247, 340)])
circulo.add([Circulo(20, 340)])
esfera.add([Esfera(314, 340)])
cubo.add([Cubo(182, 340)])
sprites.add([cuadrado,rectangulo,triangulo,circulo,esfera,cubo])
temporizador = pygame.time.Clock()
while not salir:
sprites.update()
m = pygame.mouse.get_pressed()
if m[0] == 1:
(mouse_x,mouse_y) = pygame.mouse.get_pos()
if (mouse_x > 102 and mouse_x < 182) and (mouse_y > 340 and mouse_y < 420):
glu = pygame.mixer.Sound("cuadrado.wav")
glu.play()
if(mouse_x > 397 and mouse_x < 477)and(mouse_y > 340 and mouse_y < 420):
glu = pygame.mixer.Sound("rectangulo.wav")
glu.play()
if(mouse_x > 247 and mouse_x < 327)and(mouse_y > 340 and mouse_y < 420):
glu = pygame.mixer.Sound("triangulo.wav")
glu.play()
if(mouse_x > 20 and mouse_x < 100)and(mouse_y > 340 and mouse_y < 420):
glu = pygame.mixer.Sound("circulo.wav")
glu.play()
if(mouse_x > 314 and mouse_x < 394)and(mouse_y > 340 and mouse_y < 420):
glu = pygame.mixer.Sound("esfera.wav")
glu.play()
if(mouse_x > 182 and mouse_x < 262)and(mouse_y > 340 and mouse_y < 420):
glu = pygame.mixer.Sound("cubo.wav")
glu.play()
screen.blit(fondo,(0, 0))
sprites.draw(screen)
pygame.display.flip()
temporizador.tick(60)
# gestion de eventos
for e in pygame.event.get():
if e.type == pygame.QUIT:
salir = True
elif e.type == pygame.KEYDOWN:
if e.unicode == 'q':
salir = True
elif e.unicode == 'f':
pygame.display.toggle_fullscreen()
|