google:HeNe Lesson 32
打開lesson32.exe
就可以開始玩遊戲了!!!!
2.模仿:File-New-Projects.GLUT
加入#include<mmsystem.h> //多媒體系統
void mouse(int button,int state,int x,int y)
{
PlaySound("C:\\users\\Desktop\\Lesson32\\data/shot.wav",NULL,SND_ASYNC);
}
glutMouseFunc(mouse); //Add a mouse Function
p.s是有聲音的哦
3.下載do,re,mi,fa,so音檔
程式碼反黃的是多加上去的
void keyboard(unsigned char key, int x, int y)
{
if(key=='1')PlaySound("C:\\Users\\user\\Desktop\\freeglut\\bin/do.wav",NULL,SND_ASYNC);
if(key=='2')PlaySound("C:\\Users\\user\\Desktop\\freeglut\\bin/re.wav",NULL,SND_ASYNC);
if(key=='3')PlaySound("C:\\Users\\user\\Desktop\\freeglut\\bin/mi.wav",NULL,SND_ASYNC);
if(key=='4')PlaySound("C:\\Users\\user\\Desktop\\freeglut\\bin/fa.wav",NULL,SND_ASYNC);
if(key=='5')PlaySound("C:\\Users\\user\\Desktop\\freeglut\\bin/so.wav",NULL,SND_ASYNC);
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitWindowSize(640,480);
glutInitWindowPosition(10,10);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("GLUT Shapes");
glutReshapeFunc(resize);
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
完成後就執行,也是會有聲音的哦!!!
沒有留言:
張貼留言