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") n=pygame.image.load("ncuadrado.png") re = n.get_rect() re.move_ip(100,100) 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()