颜色碰撞检测

 /*键盘消息处理*/ void KeyEvent(HWND hWnd) { if(GetAsyncKeyState(VK_UP)<0 ) //判断上方向键是否按下 { if(GameEngine::GetGameEngine()->m_bUp==TRUE) { g_ptMayi.y-=3; } if(GameEngine::GetGameEngine()->m_bUp=FALSE) { GameEngine::GetGameEngine()->m_bLeft=TRUE; GameEngine::GetGameEngine()->m_bRight=TRUE; //GameEngine::GetGameEngine()->m_bUp=TRUE; GameEngine::GetGameEngine()->m_bDown=TRUE; g_ptMayi.y+=0; } if(g_ptMayi.y<0) g_ptMayi.y=0; } else if(GetAsyncKeyState(VK_DOWN)<0 ) //判断下方向键是否按下 { if(GameEngine::GetGameEngine()->m_bDown==TRUE) { g_ptMayi.y+=3; } if(GameEngine::GetGameEngine()->m_bDown=FALSE) { GameEngine::GetGameEngine()->m_bLeft=TRUE; GameEngine::GetGameEngine()->m_bRight=TRUE; GameEngine::GetGameEngine()->m_bUp=TRUE; //GameEngine::GetGameEngine()->m_bDown=TRUE; g_ptMayi.y+=0; } if(g_ptMayi.y>500) g_ptMayi.y=500; //如果到达窗口下边缘,则停止移动 //if(g_ptMayi.y>g_pGE->GetHeight()-g_pFightPlane->GetHeight()) // g_ptMayi.y=g_pGE->GetHeight()-g_pFightPlane->GetHeight(); //g_pFightPlane->SetCxImage(g_pFightPlanePic[0]->GetCxImage()); //g_pFightPlane->SetDrawCxImageInfo(g_ptMayi.x,g_ptMayi.y,100,100); } else if(GetAsyncKeyState(VK_LEFT)<0 ) //判断左方向键是否按下 { dir=0; if(GameEngine::GetGameEngine()->m_bLeft==TRUE) { g_ptMayi.x-=3; } if(GameEngine::GetGameEngine()->m_bLeft=FALSE) { //GameEngine::GetGameEngine()->m_bLeft=TRUE; GameEngine::GetGameEngine()->m_bRight=TRUE; GameEngine::GetGameEngine()->m_bUp=TRUE; GameEngine::GetGameEngine()->m_bDown=TRUE; g_ptMayi.x+=0; } //如果到达窗口左边缘,则停止移动 if(g_ptMayi.x<0) g_ptMayi.x=0; //g_pFightPlane->SetCxImage(g_pFightPlanePic[1]->GetCxImage()); //g_pFightPlane->SetDrawCxImageInfo(g_ptMayi; .x,g_ptMayi; .y,80,100); } else if(GetAsyncKeyState(VK_RIGHT)<0 ) //判断右方向键是否按下 { dir=1; if(GameEngine::GetGameEngine()->m_bRight==TRUE) { g_ptMayi.x+=3; } if(GameEngine::GetGameEngine()->m_bRight=FALSE) { GameEngine::GetGameEngine()->m_bLeft=TRUE; //GameEngine::GetGameEngine()->m_bRight=TRUE; GameEngine::GetGameEngine()->m_bUp=TRUE; GameEngine::GetGameEngine()->m_bDown=TRUE; g_ptMayi.x+=0; } if(g_ptMayi.x>700) g_ptMayi.x=700; //如果到达窗口右边缘,则停止移动 //if(g_ptMayi.x>g_pGE->GetWidth()-g_pFightPlane->GetWidth()) // g_ptMayi.x=g_pGE->GetWidth()-g_pFightPlane->GetWidth(); //g_pFightPlane->SetCxImage(g_pFightPlanePic[2]->GetCxImage()); //g_pFightPlane->SetDrawCxImageInfo(g_ptMayi .x,g_ptMayi.y,80,100); } else if(GetAsyncKeyState(VK_ESCAPE)<0 ) //判断ESC键是否按下 SendMessage(hWnd,WM_CLOSE,0,0); //退出程序 else //如果没有方向键被按下 { //g_pFightPlane->SetCxImage(g_pFightPlanePic[0]->GetCxImage()); //g_pFightPlane->SetDrawCxImageInfo(g_ptMayi.x,g_ptMayi.y,100,100); } //} }

 

你可能感兴趣的:(颜色碰撞检测)