예제 #1
0
const cMapDecorator cMap::CreateDecorator(const cEntity * a_TrackedEntity)
{
	int InsideWidth = (GetWidth() / 2) - 1;
	int InsideHeight = (GetHeight() / 2) - 1;

	// Center of pixel
	int PixelX = static_cast<int>(a_TrackedEntity->GetPosX() - GetCenterX()) / static_cast<int>(GetPixelWidth());
	int PixelZ = static_cast<int>(a_TrackedEntity->GetPosZ() - GetCenterZ()) / static_cast<int>(GetPixelWidth());

	cMapDecorator::eType Type;
	int Rot;

	if ((PixelX > -InsideWidth) && (PixelX <= InsideWidth) && (PixelZ > -InsideHeight) && (PixelZ <= InsideHeight))
	{
		double Yaw = a_TrackedEntity->GetYaw();

		if (GetDimension() == dimNether)
		{
			// TODO 2014-02-19 xdot: Refine
			Rot = GetRandomProvider().RandInt(15);
		}
		else
		{
			Rot = CeilC(((Yaw - 11.25) * 16) / 360);
		}

		Type = cMapDecorator::eType::E_TYPE_PLAYER;
	}
	else
	{
		if ((PixelX > 320.0) || (PixelZ > 320.0))
		{
			;
		}

		Rot = 0;
		Type = cMapDecorator::eType::E_TYPE_PLAYER_OUTSIDE;

		// Move to border
		if (PixelX <= -InsideWidth)
		{
			PixelX = -InsideWidth;
		}
		if (PixelZ <= -InsideHeight)
		{
			PixelZ = -InsideHeight;
		}
		if (PixelX > InsideWidth)
		{
			PixelX = InsideWidth;
		}
		if (PixelZ > InsideHeight)
		{
			PixelZ = InsideHeight;
		}
	}

	return {Type, static_cast<unsigned>(2 * PixelX + 1), static_cast<unsigned>(2 * PixelZ + 1), Rot};
}
예제 #2
0
double DbgFontCenterX(double left_x, double right_x, double fontsize, unsigned int len, double ref_width, double /*ref_height*/, double display_width, double /*display_height*/)
{
	double nPointX		= CalcXW(left_x	, ref_width, display_width);
	double nMaxWidth	= CalcXW(right_x, ref_width, display_width);
	double nTxtWidth	= CalcXW(fontsize * (double)len, ref_width, display_width);
	double nCentered	= GetCenterX(nTxtWidth, nMaxWidth);
	return DbgFontX(nPointX + nCentered, display_width);
}
예제 #3
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;
}
예제 #4
0
파일: Api.cpp 프로젝트: RKX1209/Dnscript
int Api::_GetCenterX(){
  return GetCenterX();
}
예제 #5
0
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;
				}
			}
			
		}
	}
	
	
}
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();
    }
}
예제 #7
0
	Vector2 CircleCollider::GetCenter(bool relativeToEntity)
	{
		return Vector2(GetCenterX(relativeToEntity), GetCenterY(relativeToEntity));
	}