2015年4月15日 星期三

week08_02161141陳筱瑀


                                                          可以變成全屏                                                

點擊螢幕會有槍聲

 #include<stdio.h>
#include<GL/glut.h>
#include<mmsystem.h>
void display()
{
    glClearColor(0.5, 0.5, 1, 0);
    glClear(GL_COLOR_BUFFER_BIT);

    glFlush();
}
void Keyboard(unsigned char key, int x,int y)
{
    exit(0);
}
void mouse(int button, int state, int x, int y)
{
    if(state==GLUT_DOWN){
        PlaySound("Data/Shot.wav", NULL, SND_ASYNC);
        printf("Shot!!!\n");
    }
}
int main(int argc, char **argv)
{
    glutInit(&argc, argv);

    glutCreateWindow("hihihi");

    glutFullScreen();//全屏

    glutDisplayFunc(display);

    glutKeyboardFunc(Keyboard);

    glutMouseFunc(mouse);

    glutMainLoop();

}

茶壺會移動
#include<stdio.h>
#include<GL/glut.h>
#include<mmsystem.h>
float potX=-1, potY=0;
void display()
{
    glClearColor(0.5, 0.5, 1, 0);
    glClear(GL_COLOR_BUFFER_BIT);
    glPushMatrix();
        glTranslatef(potX, potY , 0);
        glutSolidTeapot(0.05);
    glPopMatrix();
    glFlush();
    potX+=0.01;
    if(potX> 1.1) potX=-1.1;
}
void Keyboard(unsigned char key, int x,int y)
{
    exit(0);
}
void mouse(int button, int state, int x, int y)
{
    if(state==GLUT_DOWN){
        PlaySound("Data/Shot.wav", NULL, SND_ASYNC);
        printf("Shot!!!\n");
    }
}
int main(int argc, char **argv)
{
    glutInit(&argc, argv);

    glutCreateWindow("hihihi");

    glutFullScreen();//全屏

    glutDisplayFunc(display);

    glutKeyboardFunc(Keyboard);

    glutMouseFunc(mouse);

    glutMainLoop();

}



沒有留言:

張貼留言