利用 glutFullScreen(); 將程式視窗變成全螢幕
畫出一個茶壺在畫面上跑
float potX = -1, potY = 0;
void display()
{
potX+=0.01;
if(potX>1.1) potX = -1.1;
glClearColor(0.5,0.5,1,0);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glTranslatef(potX,potY,0);
glutSolidTeapot(0.05);
glPopMatrix();
glFlush();
}
判斷滑鼠是否點擊到目標
void mouse(int button, int state, int x, int y)
{
if(state==GLUT_DOWN){
///PlaySound("Shot.wav",NULL,SND_ASYNC);
printf("SHOT!\n");
float mouseX = 2*x/1280.0 -1, mouseY = 2*y/1080.0-1;
if(fabs(mouseX-potX)<0.1 && fabs(mouseY-potY)<0.1){
///PlaySound("ahhhh.wav",NULL,SND_ASYNC);
printf("YOU GOT IT\n");
}
}
}
沒有留言:
張貼留言