今天做的是利用鍵盤來輸出東西 ,
還有加入了許多選擇的聲音檔,利用滑鼠點擊而來發出聲音檔 !
以下為今天老師教學的程式碼:
#include <mmsystem.h>
#include <stdio.h>
void display()
{
glutSolidTeapot(0.3);
glFlush();
}
void keyboard(unsigned char key, int x, int y)
{
if(key=='a'){printf("AAA\n");}
else if(key=='b'){printf("BBB\n");}
}
void mouse(int button, int state, int x, int y)
{
printf("now playing sound\n");
PlaySound("madmoo",NULL, SND_ASYNC);
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutCreateWindow("hello");
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMouseFunc(mouse);
glutMainLoop();
}
沒有留言:
張貼留言