2015年4月15日 星期三

Week08 徐詩涵課堂

開始製作小遊戲,加入槍聲

#include <stdio.h>
#include <GL/glut.h>
#include <mmsystem.h>
float potx=-1, poy=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.001;
     if(pot> 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");
        float mouseX = 2*x/1280.0 -1, mouseY= -(2*y/1240.0 -1);
        if( abs(mouseX-potX)<0.01 && abs(mouseY-potY)<0.01){
            printf("YA!I!GOT!IT!\n");
            PlaySound("ahh.wav", NULL,SND_ASYNC);
        }
    }
}
int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutCreateWindow("hello");
    glutFullScreen();
    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);
    glutMouseFunc(mouse);
    glutMainLoop();
}




有點快打不完,所以上船老師的screen shot



















沒有留言:

張貼留言