Week11-1
利用鍵盤控制小黑視窗
keyboard(unsigned char key, int x, int y)
{
if(key==27) exit(0);
}
按下Esc鍵,結束並顯示0
播放聲音
#include <windows.h>
void keyboard(unsigned char key, int x, int y)
{
if(key=='1') PlaySound("C:\\Users\\Administrator\\Desktop\\do_re_mi\\do.wav",NULL,SND_ASYNC);
if(key=='2') PlaySound("C:\\Users\\Administrator\\Desktop\\do_re_mi\\re.wav",NULL,SND_ASYNC);
if(key=='3') PlaySound("C:\\Users\\Administrator\\Desktop\\do_re_mi\\mi.wav",NULL,SND_ASYNC);
}
使用絕對位置找出音檔並撥放,絕對位置的 \ 要改成 \\
Week11-3
播放聲音,這次要撥放的位置是相對位置,因此要先做設定
設定完之後再打上程式
#include <windows.h>int main()
{
PlaySound("C:\\Users\\Administrator\\Desktop\\do_re_mi\\do.wav",NULL,SND_SYNC);
PlaySound("C:\\Users\\Administrator\\Desktop\\do_re_mi\\fa.wav",NULL,SND_SYNC);
PlaySound("C:\\Users\\Administrator\\Desktop\\do_re_mi\\mi.wav",NULL,SND_SYNC);
PlaySound("C:\\Users\\Administrator\\Desktop\\do_re_mi\\re.wav",NULL,SND_SYNC);
PlaySound("C:\\Users\\Administrator\\Desktop\\do_re_mi\\so.wav",NULL,SND_SYNC);
}
Week11-4
沒有留言:
張貼留言