2015年4月16日 星期四

02163042_王冠閔_week8

(1)用範例學習    打光  法向量 貼圖  座標


小遊戲

點擊滑鼠出現聲音
void mouse(int button, int state, int x, int y)
{
    if(state==GLUT_DOWN){
        PlaySound("Shot.wav",NULL, SND_ASYNC);
        printf("Shot!\n");
    }
}

讓茶壺移動
glPushMatrix();
        glTranslatef(potX, potY, 0);
        glutSolidTeapot(0.05);
    glPopMatrix();

讓茶壺重新出發 
if(potX>1.1) potX=-1.1;























若擊中茶壺則發出另外的聲音
float mouseX = 2*x/1280.0 -1, mouseY = 2*y/1024.0 -1;
        if(fabs(mouseX - potX) < 0.1 && fabs(mouseY - potY)<0.1){
        PlaySound("kiss.wav",NULL, SND_ASYNC);
        printf("you got it!!!\n");
        }









沒有留言:

張貼留言