2015年4月8日 星期三

week07-02160446-蘇映瑄

過了一個連假回來
覺得心情有點疲累
但今天還是乖乖地來聽小葉老師的課了~
這份作業是跟keyboard有關的
不知道接下來加入更多程式碼後會變如何

程式碼:
#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("AAA\n");
    else if(key=='b')printf("BBB\n");
}
int main(int argc,char **argv)
{
    glutInit(&argc,argv);
    glutCreateWindow("yoyoyo");
    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);
    glutMainLoop();
}
太白癡了
加了聲音之後
整間教室好吵
都是鬼叫聲
我選的是泰山搞笑版的聲音
程式碼:
#include<GL/glut.h>
#include<mmsystem.h>
#include<stdio.h>
void display()
{
    glutSolidTeapot(0.3);
    glFlush();
}
void keyboard(unsigned char key,int x,int y)
{
    if(key=='a')printf("AAA\n");
    else if(key=='b')printf("BBB\n");
}
void mouse(int button,int state,int x,int y)
{
    printf("now playing sound\n");
    PlaySound("tarzan",NULL,SND_ASYNC);\\wav的聲音檔
}
int main(int argc,char **argv)
{
    glutInit(&argc,argv);
    glutCreateWindow("yoyoyo");
    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);
    glutMouseFunc(mouse);
    glutMainLoop();
}


程式碼:
#include<GL/glut.h>
#include<mmsystem.h>
#include<stdio.h>
void display()
{
    glutSolidTeapot(0.3);
    glFlush();
}
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("Sol.wav",NULL,SND_ASYNC);
    if(key=='6')PlaySound("La.wav",NULL,SND_ASYNC);
    if(key=='7')PlaySound("Si.wav",NULL,SND_ASYNC);
}
void mouse(int button,int state,int x,int y)
{
    printf("now playing sound\n");
    PlaySound("tarzan",NULL,SND_ASYNC);
}
int main(int argc,char **argv)
{
    glutInit(&argc,argv);
    glutCreateWindow("yoyoyo");
    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);
    glutMouseFunc(mouse);
    glutMainLoop();
}

沒有留言:

張貼留言