#include <stdio.h>
#include <windows.h> ////為了定義一些DWORD
#include <mmsystem.h> ///為了 PlaySoundA()
int main()
{
PlaySoundA("fart2.wav",NULL, SND_SYNC); ////播出音效
printf("Hello W0rld\n");
PlaySoundA("fart2.wav",NULL, SND_SYNC);
}
按滑鼠才出聲音
#include <GL/glut.h>
#include <windows.h>
#include <mmsystem.h>
void display() ///
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSwapBuffers();
}
void mouse(int botton, int state, int x,int y) ///如果按下滑鼠
{
if(state==GLUT_DOWN) PlaySoundA("fart2.wav",NULL, SND_SYNC); ////發出聲音
}
int main(int argc ,char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week12 sound");
glutMouseFunc(mouse);
glutDisplayFunc(display);
glutMainLoop();
}
加入,mp3音樂
#include "CMP3_MCI.h" ////
CMP3_MCI myMP3; ////宣告一個物件變數myMP3
int main()裡++
myMP3.Load("bgm_01.mp3");
myMP3.Play();
沒有留言:
張貼留言