2015年4月9日 星期四

week_07_02160660_楊涵雯

(1)  作業互評、品味
(2)  keyboard,mouse,UI
(3)  音效、音樂
(4)  期中考題目、答案




#include<GL/glut.h>
#include<stdio.h>

void display()
{
    glutSolidTeapot(0.3);
    glFlush();
}
void keyboard(unsigned char key, int x, int y)
{
    if(key=='a')
        printf("aaaaa\n");
    if(key=='b')
        printf("bbbbb\n");
}
int main(int argc , char ** argv)
{
    glutInit(&argc,argv);
    glutCreateWindow("hello");

    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);

    glutMainLoop();
}



加入聲音檔案~
#include  <GL/glut.h>
#include <stdio.h>
#include <mmsystem.h>
void display()
{
    glutSolidTeapot(0.3);
    glFlush();
}
void keyboard(unsigned char key,int x,int y)
{
    if(key=='a')
    {
        PlaySound("Birds.wav",NULL,SND_ASYNC);
        printf("啾啾啾\n");
    }
    if(key=='b') printf("bbbbb\n");
}
int main(int argc,char**argv)
{
    glutInit(&argc,argv);
    glutCreateWindow("hello");
    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);
    glutMainLoop();
}



增加鋼琴聲音
    if(key=='1') printf("Do.wav",NULL,SND_ASYNC);
    if(key=='2') printf("Ra.wav",NULL,SND_ASYNC);
    if(key=='3') printf("Mi.wav",NULL,SND_ASYNC);
    if(key=='4') printf("Fa.wav",NULL,SND_ASYNC);
    if(key=='5') printf("Sol.wav",NULL,SND_ASYNC);
    if(key=='6') printf("La.wav",NULL,SND_ASYNC);
    if(key=='7') printf("Si.wav",NULL,SND_ASYNC);

沒有留言:

張貼留言