コード例 #1
0
/**
 * CheckBoxObject provides a basic bounding box.
 */
std::vector<RotatedRectangle> CheckBoxObject::GetHitBoxes() const
{
    std::vector<RotatedRectangle> boxes;
    RotatedRectangle rectangle;
    rectangle.angle = GetAngle()*3.14/180.0f;
    rectangle.center.x = GetX()+GetCenterX();
    rectangle.center.y = GetY()+GetCenterY();
    rectangle.halfSize.x = GetWidth()/2;
    rectangle.halfSize.y = GetHeight()/2;

    boxes.push_back(rectangle);
    return boxes;
}
コード例 #2
0
ファイル: Api.cpp プロジェクト: RKX1209/Dnscript
int Api::_GetCenterY(){
  return GetCenterY();
}
コード例 #3
0
VOID CDrawingObject::Translate(FLOAT fdx, FLOAT fdy, BOOL bInertia)
{
    m_fdX = fdx;
    m_fdY = fdy;

    FLOAT fOffset[2];
    fOffset[0] = m_fOX - m_fdX;
    fOffset[1] = m_fOY - m_fdY;

    // Translate based on the offset caused by rotating 
    // and scaling in order to vary rotational behavior depending 
    // on where the manipulation started
    
    if(m_fAngleApplied != 0.0f)
    {
        FLOAT v1[2];
        v1[0] = GetCenterX() - fOffset[0];
        v1[1] = GetCenterY() - fOffset[1];

        FLOAT v2[2];
        RotateVector(v1, v2, m_fAngleApplied);

        m_fdX += v2[0] - v1[0];
        m_fdY += v2[1] - v1[1];
    }

    if(m_fFactor != 1.0f)
    {
        FLOAT v1[2];
        v1[0] = GetCenterX() - fOffset[0];
        v1[1] = GetCenterY() - fOffset[1];

        FLOAT v2[2];
        v2[0] = v1[0] * m_fFactor;
        v2[1] = v1[1] * m_fFactor;
        
        m_fdX += v2[0] - v1[0];
        m_fdY += v2[1] - v1[1];
    }

    m_fXI += m_fdX;
    m_fYI += m_fdY;

    // The following code handles the effect for 
    // bouncing off the edge of the screen.  It takes
    // the x,y coordinates computed by the inertia processor
    // and calculates the appropriate render coordinates
    // in order to achieve the effect.

    if (bInertia)
    {
        ComputeElasticPoint(m_fXI, &m_fXR, m_iBorderX);
        ComputeElasticPoint(m_fYI, &m_fYR, m_iBorderY);
    }
    else
    {
        m_fXR = m_fXI;
        m_fYR = m_fYI;

        // Make sure it stays on screen
        EnsureVisible();
    }
}
コード例 #4
0
ファイル: Player.cpp プロジェクト: copyzerov3/Pacman
void Player::Update()
{
	Sphere::Update();

	Map* map = (Map*)GetParent();
	if (map)
	{	
		int x,y; 
		if (DOWN)
		{
			x = round(GetCenterX() / GetWidth());
			y = (round((map->GetScreenHeight() - GetCenterY()) / GetWidth())) + 1;
			if ((x == 9) && (y == 8))
			{
				
			}
			else
			{
				if (!map->IsBoundary(x, y) || !map->GetBoundary(x, y)->Contains(this))
				{
					Score += map->CheckPlayerEatPellet();
					m_transformation[1][3] -= MoveSpeed;
					LastMove = 2;
				}
			}
		}
		if (UP)
		{
			x = round(GetCenterX() / GetWidth());
			y = round((map->GetScreenHeight() - GetCenterY()) / GetWidth()) - 1;
			if (!map->IsBoundary(x, y) || !map->GetBoundary(x, y)->Contains(this))
			{
				Score += map->CheckPlayerEatPellet();
				m_transformation[1][3] += MoveSpeed;
				LastMove = 0;
			}
		}
		if (LEFT)
		{
			x = round(GetCenterX() / GetWidth()) - 1;
			y = round((map->GetScreenHeight() - GetCenterY()) / GetWidth());
			if (!map->IsBoundary(x, y) || !map->GetBoundary(x, y)->Contains(this))
			{
				Score += map->CheckPlayerEatPellet();
				m_transformation[0][3] -= MoveSpeed;
				LastMove = 3;
				if (m_transformation[0][3] <=0)
				{
					
					m_transformation[0][3] = map->GetWidth();
					LastMove = 1;
				}
			}
		}
		if (RIGHT)
		{
			x = round(GetCenterX() / GetWidth()) + 1;
			y = round((map->GetScreenHeight() - GetCenterY()) / GetWidth());
			if (!map->IsBoundary(x, y) || !map->GetBoundary(x, y)->Contains(this))
			{
				Score += map->CheckPlayerEatPellet();
				m_transformation[0][3] += MoveSpeed;
				LastMove = 2;
				if (m_transformation[0][3] > map->GetWidth() - GetRadius())
				{
					
					m_transformation[0][3] = 0;
					LastMove = 3;
				}
			}
			
		}
	}
	
	
}
コード例 #5
0
	Vector2 CircleCollider::GetCenter(bool relativeToEntity)
	{
		return Vector2(GetCenterX(relativeToEntity), GetCenterY(relativeToEntity));
	}