2016-06-05 3 views
-1

도와주세요. 진행중인 게임에 음악을 업로드 할 수없는 것 같습니다. 일주에파이 게임에 음악을로드 할 수 없으므로

import sys, random, pygame, time 
from pygame.locals import * 
pygame.init() 

screen = pygame.display.set_mode((600,500)) 
pygame.display.set_caption("game") 
myfont = pygame.font.SysFont("cambria", 19) 
myfont2 = pygame.font.SysFont("cambria", 45) 
myfont3 = pygame.font.SysFont("cambria", 30) 

#music 

pygame.mixer.music.load('sddmusic.mp3') 
pygame.mixer.music.play(0) 



def print_text(font, x, y, text, color): 
    imgText = font.render(text, True, color) 
    screen.blit(imgText, (x,y)) 

game = False 
white = 255,255,255 

mouse_down_x = mouse_down_y = 0 
mouse_down = 0 
while True: 
    for event in pygame.event.get(): 
     if event.type == QUIT: 
      pygame.quit() 
      sys.exit() 
     elif event.type == MOUSEBUTTONDOWN: 
      mouse_down = event.button 
      mouse_down_x, mouse_down_y = event.pos 

    screen.fill((85,107,47)) 

    #print_text(myfont,0,0, str(mouse_down), white) 
    #print_text(myfont,0,15, str(mouse_down_x), white) 
    #print_text(myfont,0,30, str(mouse_down_y), white) 

    if game == True: 
     pygame.draw.line(screen, white, (100,0), (100,600), 20) 
     pygame.draw.line(screen, white, (500,0), (500,600), 20) 
     time_get = time.clock() - time_start 


     if time_get > 1: 
      print_text(myfont, 240,0 ,"Hello?", (255,255,255)) 
     if time_get > 1.75: 
      print_text(myfont, 240,50, "Commander?", (255,255,255)) 
     if time_get > 2.2: 
      print_text(myfont, 240,100, "Do you copy?",(255,255,255)) 

    else: 
     pygame.draw.rect(screen, white,(204,176,200,40),2) 
     print_text(myfont2, 100, 100,"Operation L.A.U.N.C.H", (255,255,255)) 
     print_text(myfont3,270,176, "Start", white) 
     pygame.draw.rect(screen, white,(204,280,200,40),2) 
     print_text(myfont3,270,280, "Quit", white) 

     if mouse_down == 1 and mouse_down_x > 204 and mouse_down_y > 176 and mouse_down_x < 404 and mouse_down_y < 216: 
      game = True 
      mouse_down = 0 
      mouse_down_x = 0 
      mouse_down_y = 0 
      time_start = time.clock() 


     if mouse_down == 1 and mouse_down_x > 204 and mouse_down_y > 280 and mouse_down_x < 404 and mouse_down_y < 320: 
      pygame.quit() 
      sys.exit() 




    pygame.display.update() 
+0

문제를 조사하기 위해 취한 조치는 무엇입니까? – Alex

+0

나는 공정한 것을 연구하고 youtube 비디오를 보았다. 나는 또한 mp3, wav, ogg와 같은 다른 파일 형식을 시도했다. 나는 주된 문제는 어떤 이유로 mp3 파일을 인식하지 못한다는 것입니다. 이제는 더 명확 해지기를 바랍니다 :) –

+0

docs는 "MP3 지원이 제한되어 있다는 것을 알고 있습니다. 일부 시스템에서는 지원되지 않는 형식으로 인해 데비안 리눅스와 같은 프로그램이 중단 될 수 있습니다. 대신 OGG를 사용해보십시오." wav와 ogg는 작동합니까? – rrauenza

답변

0

내가 당신의 문제가 생각 때문에 그것은 사람이 바로 나에게 돌아 왔을 경우 가 좋은 것 ... "로드 할 수 없습니다"라는 오류와 함께 온다, 이것은 중요한 일이다 다음과 같은 이유로 인해
1) 파일로 이동하여> 저장 (단축키 : Ctrl + Shift + S)하고 음악이 저장된 동일한 주소에 파이썬 파일을 저장하십시오.

제안 :
mp3를 wav로 변환 해보세요. 잘 작동합니다.

+0

감사합니다. :) –

+0

그런 다음 ✔ 왼쪽 상단의 체크 표시를 클릭하여 대답을 수락 할 수 있습니다. –

0

mp3의 전체 경로를 입력하십시오. 예 :

pygame.mixer.music.load('C:/Users/path/to/your/file/sddmusic.mp3') 
관련 문제