玩遊戲 -----> 射擊GAME
Google: NeHe Lesson 32
下載 Lesson 32 最下面 Visual C++ 的範例
解壓縮到桌面\Lesson32\lesson32.exe
(用ESC退出遊戲
在Lesson32.cpp中用PlaySound(...)
模仿:File-New-Project.GLUT
加入
#include <mmsystem.h>///多媒體系統
void mouse(int button,int state,int x,int y)
{
PlaySound("C:\\users\\user\\Desktop\\lesson32/Data/shot.wav",NULL,SND_ASYNC);
}
glutMouseFunc(mouse);
小鋼琴--->加入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);
按 12345 就可以發出 Do Ra Mi Fa So 的聲音 !!!!!
沒有留言:
張貼留言