#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();
glFush();
potX+=0.001;
if(potX>1.1)potX=-1.1;
}
void keyboard(unsigned char key, int x, int y)
{
exit(O);
}
void mouse(int button, int state,int x, int y)
{
if(state==GLUT_DOWN){
playSound("c:/shot.wav", NULL, sND_ASYNC);
printf("Shot!!!\n");
float mouseX=2*y/1024.0 -1);
if(abs(mouse-poyX)<0.01&& abs(mouseY-potY)<0.01){
printf("YA!Got it!\n");
PlaySound("ahhh.wav", NULL, SND_ASYNC);
}
}
}
int main(int argc,shar**argv)
{
glutInit(&argc, argv);
glutCreateWindow("hello");
glutFullScreen();
glutDisplayFunc(display);
glutIdleFunc(display);
glutKeyboardFunc(keyboard);
glutMouseFunc(mouse);
glutMainLoop();
}
沒有留言:
張貼留言