Пример #1
0
SoccerPitch::SoccerPitch(int cx, int cy): m_cxClient(cx),
										  m_cyClient(cy),
										  m_bPaused(false)				
{
  //GoalWidth指的是得分區厚度
  int GoalWidth = 200;
  m_pPlayingArea = new Region(20, 20, cx-20, cy-20);	
  //
   m_pRedGoal  = new Goal(V2D(m_pPlayingArea->Left(), (cy-GoalWidth)/2),
                          V2D(m_pPlayingArea->Left(), cy - (cy-GoalWidth)/2),
                          V2D(1,0));
  m_pBlueGoal = new Goal(V2D( m_pPlayingArea->Right(), (cy-GoalWidth)/2),
                          V2D(m_pPlayingArea->Right(), cy - (cy-GoalWidth)/2),
                          V2D(-1,0));							  	
  //建立外牆
  V2D TopLeft(m_pPlayingArea->Left(), m_pPlayingArea->Top());                                        
  V2D TopRight(m_pPlayingArea->Right(), m_pPlayingArea->Top());
  V2D BottomRight(m_pPlayingArea->Right(), m_pPlayingArea->Bottom());
  V2D BottomLeft(m_pPlayingArea->Left(), m_pPlayingArea->Bottom());                                   
  m_vecWalls.push_back(Wall(BottomLeft, m_pRedGoal->RightPost()));
  m_vecWalls.push_back(Wall(m_pRedGoal->LeftPost(), TopLeft));
  m_vecWalls.push_back(Wall(TopLeft, TopRight));
  m_vecWalls.push_back(Wall(TopRight, m_pBlueGoal->LeftPost()));
  m_vecWalls.push_back(Wall(m_pBlueGoal->RightPost(), BottomRight));
  m_vecWalls.push_back(Wall(BottomRight, BottomLeft));

}
Пример #2
0
//------------------------------- ctor -----------------------------------
//------------------------------------------------------------------------
SoccerPitch::SoccerPitch(int cx, int cy):m_cxClient(cx),
    m_cyClient(cy),
    m_bPaused(false),
    m_bGoalKeeperHasBall(false),
    m_Regions(NumRegionsHorizontal*NumRegionsVertical),
    m_bGameOn(true)
{
    //define the playing area
    m_pPlayingArea = new Region(20, 20, cx-20, cy-20);

    //create the regions
    CreateRegions(PlayingArea()->Width() / (double)NumRegionsHorizontal,
                  PlayingArea()->Height() / (double)NumRegionsVertical);

    //create the goals
    m_pRedGoal  = new Goal(Vector2D( m_pPlayingArea->Left(), (cy-Prm.GoalWidth)/2),
                           Vector2D(m_pPlayingArea->Left(), cy - (cy-Prm.GoalWidth)/2),
                           Vector2D(1,0));



    m_pBlueGoal = new Goal( Vector2D( m_pPlayingArea->Right(), (cy-Prm.GoalWidth)/2),
                            Vector2D(m_pPlayingArea->Right(), cy - (cy-Prm.GoalWidth)/2),
                            Vector2D(-1,0));


    //create the soccer ball
    m_pBall = new SoccerBall(Vector2D((double)m_cxClient/2.0, (double)m_cyClient/2.0),
                             Prm.BallSize,
                             Prm.BallMass,
                             m_vecWalls);


    //create the teams
    m_pRedTeam  = new SoccerTeam(m_pRedGoal, m_pBlueGoal, this, SoccerTeam::red);
    m_pBlueTeam = new SoccerTeam(m_pBlueGoal, m_pRedGoal, this, SoccerTeam::blue);

    //make sure each team knows who their opponents are
    m_pRedTeam->SetOpponents(m_pBlueTeam);
    m_pBlueTeam->SetOpponents(m_pRedTeam);

    //create the walls
    Vector2D TopLeft(m_pPlayingArea->Left(), m_pPlayingArea->Top());
    Vector2D TopRight(m_pPlayingArea->Right(), m_pPlayingArea->Top());
    Vector2D BottomRight(m_pPlayingArea->Right(), m_pPlayingArea->Bottom());
    Vector2D BottomLeft(m_pPlayingArea->Left(), m_pPlayingArea->Bottom());

    m_vecWalls.push_back(Wall2D(BottomLeft, m_pRedGoal->RightPost()));
    m_vecWalls.push_back(Wall2D(m_pRedGoal->LeftPost(), TopLeft));
    m_vecWalls.push_back(Wall2D(TopLeft, TopRight));
    m_vecWalls.push_back(Wall2D(TopRight, m_pBlueGoal->LeftPost()));
    m_vecWalls.push_back(Wall2D(m_pBlueGoal->RightPost(), BottomRight));
    m_vecWalls.push_back(Wall2D(BottomRight, BottomLeft));

    ParamLoader* p = ParamLoader::Instance();
}
Пример #3
0
void CSwingBorderWnd::OnPaint() 
{
	CWnd::OnPaint();
	CPaintDC dc(this); // device context for painting
	
	CDC *pDC = GetWindowDC();
	CRect rectItem, pRect;
	GetWindowRect(pRect);
	GetClientRect(rectItem);

	rectItem.right = rectItem.left + pRect.Width();
	rectItem.bottom = rectItem.top + pRect.Height();

	CPoint TopLeft(rectItem.left, rectItem.top);
	CPoint BottomRight(rectItem.right - 1, rectItem.bottom - 1);
	CPoint TopRight(rectItem.right - 1, rectItem.top);
	CPoint BottomLeft(rectItem.left, rectItem.bottom - 1);

	pDC->SelectObject(&nDarkBorder);
	pDC->MoveTo(TopLeft);
	pDC->LineTo(TopRight);
	pDC->MoveTo(TopLeft);
	pDC->LineTo(BottomLeft);

	pDC->MoveTo(BottomLeft.x, BottomLeft.y - 1);
	pDC->LineTo(BottomRight.x, BottomRight.y - 1);
	pDC->MoveTo(BottomRight.x - 1, BottomRight.y);
	pDC->LineTo(TopRight.x - 1, TopRight.y);

	pDC->SelectObject(&nWhiteBorder);

	pDC->MoveTo(BottomLeft);
	pDC->LineTo(BottomRight);
	pDC->MoveTo(BottomRight);
	pDC->LineTo(TopRight);

	pDC->MoveTo(TopLeft.x + 1, TopLeft.y + 1);
	pDC->LineTo(TopRight.x - 1, TopRight.y + 1);
	pDC->MoveTo(TopLeft.x + 1, TopLeft.y + 1);
	pDC->LineTo(BottomLeft.x + 1, BottomLeft.y - 1);
	ReleaseDC(pDC);

	// TODO: Add your message handler code here
	
	// Do not call CWnd::OnPaint() for painting messages
}
Пример #4
0
FVector2D UEdGraph::GetGoodPlaceForNewNode()
{
	FVector2D BottomLeft(0,0);

	if(Nodes.Num() > 0)
	{
		UEdGraphNode* Node = Nodes[0];
		BottomLeft = FVector2D(Node->NodePosX, Node->NodePosY);
		for(int32 i=1; i<Nodes.Num(); i++)
		{
			Node = Nodes[i];
			if ( Node )
			{
				BottomLeft.X = FMath::Min<float>(BottomLeft.X, Node->NodePosX);
				BottomLeft.Y = FMath::Max<float>(BottomLeft.Y, Node->NodePosY);
			}
		}
	}

	return BottomLeft + FVector2D(0, 256);
}
Пример #5
0
void CSwingCheckBox::DrawItem(LPDRAWITEMSTRUCT lpDIS) 
{
	CDC* pDC = CDC::FromHandle(lpDIS->hDC);
	CRect rectItem(lpDIS->rcItem);

	CRect rectCheck(rectItem);
	rectCheck.right = rectCheck.left + 12;
	rectCheck.bottom = rectCheck.top + 12;

	CPoint TopLeft(rectCheck.left, rectCheck.top);
	CPoint BottomRight(rectCheck.right, rectCheck.bottom);
	CPoint TopRight(rectCheck.right, rectCheck.top);
	CPoint BottomLeft(rectCheck.left, rectCheck.bottom);
	// TODO: Add your code to draw the specified item

	pDC->SelectObject(&nInactiveBrush);
	pDC->SelectStockObject(NULL_PEN);
	pDC->Rectangle(rectItem);

	pDC->SelectObject(&nDarkBorder);
	pDC->MoveTo(TopLeft);
	pDC->LineTo(TopRight);
	pDC->MoveTo(TopLeft);
	pDC->LineTo(BottomLeft);

	pDC->MoveTo(BottomLeft.x, BottomLeft.y - 1);
	pDC->LineTo(BottomRight.x, BottomRight.y - 1);
	pDC->MoveTo(BottomRight.x - 1, BottomRight.y);
	pDC->LineTo(TopRight.x - 1, TopRight.y);

	pDC->SelectObject(&nWhiteBorder);

	pDC->MoveTo(BottomLeft);
	pDC->LineTo(BottomRight);
	pDC->MoveTo(BottomRight);
	pDC->LineTo(TopRight);

	pDC->MoveTo(TopLeft.x + 1, TopLeft.y + 1);
	pDC->LineTo(TopRight.x - 1, TopRight.y + 1);
	pDC->MoveTo(TopLeft.x + 1, TopLeft.y + 1);
	pDC->LineTo(BottomLeft.x + 1, BottomLeft.y - 1);

	pDC->SelectStockObject(DEFAULT_GUI_FONT);
	pDC->TextOut(16, 0, m_strCaption);

	if (m_Checked)
	{
		pDC->SelectObject(&nCheck);
		pDC->MoveTo(2, 3);
		pDC->LineTo(3, 8);
		pDC->MoveTo(3, 9);
		pDC->LineTo(9, 3);
	}

	if (lpDIS->itemState & ODS_FOCUS)
	{
		pDC->SelectObject(&nSelectedBorder);
		pDC->SelectStockObject(NULL_BRUSH);
		int xlen = pDC->GetTextExtent(m_strCaption).cx;

		pDC->Rectangle(15, 0, 13 + xlen + 3, 12);
	}

}