2018年5月7日 星期一

Week11 想跟去吃小火鍋

1.下載freeglut
開啟codeblocks >> GLUT
下載音樂>>WAV download
記得要把音樂放在freeglut的bin

#include <mmsystem.h>

PlaySound("madmoo.wav",NULL,SND_ASYNC);

(加這兩句)

2.
#include <stdio.h>
#include <windows.h>
#include <mmsystem.h>
int main()
{
    PlaySound("madmoo.wav",NULL,SND_ASYNC);
    printf("Hello world, please input a number:");
    int n;
    scanf("%d",&n);
}


3.
鍵盤鋼琴
remember將音符放在GLUT的bin裡面

#include <mmsystem.h>
static void key(unsigned char key, int x, int y)
{
    switch (key)
    {
        case '1':PlaySound("Do.wav",NULL,SND_ASYNC);
            break;
        case '2':PlaySound("Re.wav",NULL,SND_ASYNC);
            break;
        case '3':PlaySound("Mi.wav",NULL,SND_ASYNC);
            break;
        case '4':PlaySound("Fa.wav",NULL,SND_ASYNC);
            break;
        case '5':PlaySound("Sol.wav",NULL,SND_ASYNC);
            break;
        case '6':PlaySound("La.wav",NULL,SND_ASYNC);
            break;
        case '7':PlaySound("Si.wav",NULL,SND_ASYNC);
            break;

4.
滑鼠發聲
void mouse(int button,int state,int x,int y)
{
    if(state==GLUT_DOWN)PlaySound("shot.wav",NULL,SND_ASYNC);
}
int main(int argc, char *argv[])
{
    PlaySound("madmoo.wav",NULL,SND_ASYNC);
    glutInit(&argc, argv);
    glutInitWindowSize(640,480);
    glutInitWindowPosition(10,10);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);

    glutCreateWindow("GLUT Shapes");

    glutReshapeFunc(resize);
    glutDisplayFunc(display);
    glutKeyboardFunc(key);
    glutIdleFunc(idle);
    glutMouseFunc(mouse);

下週考試內容:(TRT 旋轉   讓關節會動的重要程式碼)






glutPushMatrix();

glTranslatef(-0.5,0.35,0);

glRotatef(-angle,0,0,1);

glTranslatef(-0.3,0,0);

drawArm();

glutPopMatrix();

沒有留言:

張貼留言