課堂作業一
玩有聲音的遊戲
課堂作業二
使用滑鼠點擊觸發音樂
課堂作業二
使用滑鼠點擊觸發音樂
#include<mmsystem.h>
/* Program entry point */
void mouse(int button, int state, int x, int y)
{
PlaySound("C:\\Users\\user\\Desktop\\Lesson32\\data/shot.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(key);
glutIdleFunc(idle);
glutMouseFunc(mouse);
讀入音檔
#include<mmsystem.h>
#include "CMP3_MCI.h"
CMP3_MCI myMP3;
/* Program entry point */
void mouse(int button, int state, int x, int y)
{
PlaySound("C:\\Users\\user\\Desktop\\Lesson32\\data/shot.wav",NULL,SND_ASYNC);
}
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);
}
鍵盤數字觸發音樂
int main(int argc, char *argv[])
{
myMP3.Load("C:\\Users\\user\\Desktop\\04160604/yukai.mp3");
myMP3.Play();
沒有留言:
張貼留言