2024年5月30日 星期四

探索比其寶的十大奧秘 15

week15-1_PlaySound


 #include <windows.h> ///要放在第一行

PlaySound("C:/Do.wav",NULL,SND_SYNC);///SYNC同步等待

PlaySound("C:/mykbeat.wav"///檔案要丟C槽,NULL,SND_ASYNC); ///播音樂,不同步/不等待ASYNC


week15-2_PlaySound_empty

#include <windows.h>

#include <stdio.h>
int main(int argc, char *argv[])

{
    ///PlaySound("C:/Do.wav",NULL,SND_SYNC);
    PlaySound("C:/mykbeat.wav",NULL,SND_ASYNC);///不等待,後面沒程式碼的話就會很快結束
    printf("輸入數字:");
    int n;
    scanf("%d",&n);///只要不scanf音樂就會一直播

 switch (key)
    {
        case'1':
            PlaySound("Do.wav",NULL,ASND_SYNS);
            break;
            case'2':
            PlaySound("Re.wav",NULL,ASND_SYNS);
            break;
            case'3':
            PlaySound("Mi.wav",NULL,ASND_SYNS);
            break;

按數字就可以切換音樂

week15-3_CMP3_MCI

#include "CMP3_MCI.h"//"
CMP3_MCI myMP3;///宣告一個變數


 myMP3.Load("song.mp3");
    myMP3.Play();


week15-4_mouse_motion_translate_rotate
拿出之前的11GLUT 行程式碼
目標:先能移動,旋轉,陣列
float angleX[10]={},angleY[10]={};陣列

void mouse(int button,int state,int x,int y){
    oldX = x;
    oldY = y;
}
void motion(int x,int y){
    teapotX+=(x-oldX)/150.0;
    teapotY-=(y-oldY)/150.0;
    oldX = x;
    oldY = y;
}

printf("glTranslatef(%.3f,%.3f,0);\n",teapotX,teapotY);///移動她讓她幫妳寫程式碼,會跑出來座標

glutPostRedisplay();更新

///glTranslatef(teapotX,teapotY,0);///移動


glRotatef(angleX[0],0,0,1);///旋轉
angleX[0] += (x-oldX);///旋轉















沒有留言:

張貼留言