2021年4月26日 星期一

Week_10 2021.04.26

 1. 聲音音效

    1. 開啟GLUT檔

    2. 輸入程式碼

        #include <windows.h>

        int main()

        {

            PlaySound("pig.wav",NULL,SND_SYNC);   ///SND_SYNC代表等待同步

        }

    3. 記得!!檔案要放在(in C:\Users\Administrator\Desktop\freeglut\bin)資料夾內

2. 做出do re mi fa so

    1. 更改程式碼

          #include <windows.h>

#include <stdio.h>

int main()

{

    char c;

    while(1)

    {

        c = getchar();

        if(c=='1') PlaySound("do.wav",NULL,SND_ASYNC);   ///SND_ASYNC代表不等待同步

        if(c=='2') PlaySound("re.wav",NULL,SND_ASYNC);

        if(c=='3') PlaySound("mi.wav",NULL,SND_ASYNC);

        if(c=='4') PlaySound("fa.wav",NULL,SND_ASYNC);

        if(c=='5') PlaySound("so.wav",NULL,SND_ASYNC);

    }

}

3. 茶壺 + 音效

    1. 開啟GLUT檔

    2. 輸入程式碼

github
----------------------------------------------------------------------------------------------------------

     3. 如圖


4. 加入滑鼠射擊音效

    1. 輸入程式碼

github
----------------------------------------------------------------------------------------------------------

    2. 如圖 


5. 播音樂

    1. 輸入程式碼

github
----------------------------------------------------------------------------------------------------------
注意!!!
#include "CMP3_MCI.h"
CMP3_MCI mp3;

int main(int argc,char **argv)
{
    mp3.Load("music.mp3");   ///音樂要放在檔案的資料夾內
    mp3.Play();

}

    2. 如圖


 6. 打光

    1. 輸入程式碼

github
----------------------------------------------------------------------------------------------------------
注意!!!     
 const  GLfloat light_position[ ] = { 2.0f , -5.0f , 5.0f , 0.0f };   ///y軸負數會變成鬼片效果








 

沒有留言:

張貼留言

Week18期末作業(橘貓的跳舞熊熊)

 期末作業(橘貓的跳舞熊熊) 影片: https://youtu.be/R89tptMaQZw 程式碼: #include <opencv/highgui.h> #include <opencv/cv.h> #include <GL/glut.h...