(2)聲音

void mouse(int button,int state,int x,int y)///Add a mouse Function
{
PlaySound("C:\\Users\\user\\Desktop\\lesson32\\Lesson32/Data/shot.wav",NULL,SND_ASYNC);
}///copy this line ///要把檔名裡面的目錄裡面的斜線,從\ 變成(A)\\ OR (B)/

glutMouseFunc(mouse)///Add a mouse Function

(3)小遊戲
ToDo:玩遊戲,射擊
Google:NeHe Lesson 32
下載 Lesson最下面
Visual C++的範例
解壓縮桌面\Lesson32\lesson32.exe應用程式
ToDo:小鋼琴加入keyboard
void keyboard(unsigned char key,int x,int y)
{
if(key=='1') PlaySound("do.wav",NULL,SND_ASYNC);
if(key=='2') PlaySound("re.wav",NULL,SND_ASYNC);
if(key=='3') PlaySound("mi.wav",NULL,SND_ASYNC);
if(key=='4') PlaySound("fa.wav",NULL,SND_ASYNC);
if(key=='5') PlaySound("so.wav",NULL,SND_ASYNC);
}
glutKeyboardFunc(keyboard);

#inlcude "CMP3_MCI.h"///(1)放在同一個程式碼專案目錄中
CMP3_MCI myMP3;///宣告一個變數,叫myMP3
myMP3.Load("C:\\Users\\user\\Desktop\\2017\\music.mp3");///讀取mp3檔案
myMP3.Play();///啟動檔案

沒有留言:
張貼留言