2017年4月24日 星期一

Week08 20170424 芷萱的課堂筆記

作業一:

  • 玩射擊遊戲

        Google : NeHe Lesson 32












  • 開始試玩遊戲
      ※確定射擊時有聲音

      作業二:















開啟CodeBlocks/New/Project..

   利用GLUT專案
  • 增加部分程式 讓視窗能出射擊聲
     #include <mmsystem.h>  ///多媒體系統     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[])    {        glutMouseFunc(mouse);  ///Add a mouse Function    }
  • 增加void keyboard{} 利用鍵盤發出鋼琴聲wav檔
      將音樂檔放入freeglut/bin資料夾中
     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);     } 
     
  • 增加部分程式碼 讓視窗可以跑出mp3檔
     #include "CMP3_MCI.h" ///(1)放在同一個程式碼專案的目錄中
     CMP3_MCI myMP3;///(2)宣告一個變數,叫myMP3      int main(int argc, char *argv[])     {///(3)        myMP3.Load("C:/Users/user/Desktop/04160391_hw1/yukai.mp3");        myMP3.Play(); ///(4)play the file     }




 

沒有留言:

張貼留言