2023年4月27日 星期四

好想放假week11

 week11

step01-1

打開codeblock開啟專案

在main.cpp裡先找到 key

寫出此程式讓小黑出現1234

#include <GL/glut.h>

void display()

{

    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

    glutSolidTeapot(0.3);

    glutSwapBuffers();

}

void keyboard(unsigned char key,int x,int y)

{

    if(key==27) exit(1234);

}

int main(int argc, char** argv)

{

        glutInit(&argc,argv);

        glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);

        glutCreateWindow("week11");


        glutDisplayFunc(display);

        glutKeyboardFunc(keyboard);


        glutMainLoop();

}


step01-2

開啟先的專案

複製week11-1的main.cpp再增加(紅色),\多打一個變成\\

#include <windows.h>

#include <GL/glut.h>

void display()

{

    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

    glutSolidTeapot(0.3);

    glutSwapBuffers();

}

void keyboard(unsigned char key,int x,int y)

{

    if(key=='1')    PlaySound("C:\\Users\\Administrator\\Desktop\\do-re-mi\\do.wav",NULL,SND_ASYNC);

    if(key=='2')    PlaySound("C:\\Users\\Administrator\\Desktop\\do-re-mi\\re.wav",NULL,SND_ASYNC);

    if(key=='3')    PlaySound("C:\\Users\\Administrator\\Desktop\\do-re-mi\\mi.wav",NULL,SND_ASYNC);

}

int main(int argc, char** argv)

{

        glutInit(&argc,argv);

        glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);

        glutCreateWindow("week11");


        glutDisplayFunc(display);

        glutKeyboardFunc(keyboard);


        glutMainLoop();

}


step02-1

開啟新的codeblock,把音效用cpp播放


再打奇怪的咒語PlayGround(winmm)

                   絕對路徑和相對路徑比較
絕對路徑
相對路徑
step02-2
開啟新的專案
把音檔複製放進week11-4裡

在137行main()上面多加
#include "CMP3_MCI.h"
CMP3_MCI myMP3;
main()裡面多加
char filename[]="C:\\Users\\Administrator\\Desktop\\do-re-mi\\suzume.mp3";
 myMP3.Load(filename);
  myMP3.Play();

step03-1更改檔案執行位置




把一長串改成.
再修改程式碼即可
/// char filename[]="C:\\Users\\Administrator\\Desktop\\do-re-mi\\Overdose.mp3";這行註解掉
    myMP3.Load("overdose.mp3");
step03-2
dll檔無法上傳github,gitignore會把gll檔忽略,所以要更改它


用notepad++開啟
之後就上傳github








沒有留言:

張貼留言