Example #1
0
void Player::Follow(Vector2D<float> &a)
{
	if ((Pos.GetX() != a.GetX()) || (Pos.GetY() != a.GetY()))
	{
		Velocity.SetX(((a.GetX() - Pos.GetX()) * Time::fDeltaTime)* speed);
		Velocity.SetY(((a.GetY() - Pos.GetY()) * Time::fDeltaTime)* speed);
	}
}
Example #2
0
Enemy::Enemy(Vector2D pos, Vector2D targetPos)
{
	DEBUG_MSG("Constructing Enemy");

	m_currentState = Walking;
	m_attackingRange = 50;

	//Set positions and dimensions of sprites
	m_position = Vector2D(pos.GetX() - 23.5f, pos.GetY() - 25.0f);
	m_targetPosition = targetPos;

	m_destination.x = m_position.GetX();
	m_destination.y = m_position.GetY();
	m_destination.w = 47;
	m_destination.h = 50;

	//Set source rectangle to first frame of animation
	m_Source.x = 0;
	m_Source.y = 0;
	m_Source.w = m_destination.w;
	m_Source.h = m_destination.h;
	m_speed = 50.0f;

	//Get angle between enemy and target
	float deltaX = m_targetPosition.GetX() - GetPosition().GetX();
	float deltaY = m_targetPosition.GetY() - GetPosition().GetY();

	m_angle = atan2(deltaY, deltaX) * 180.0 / PI;	//gets angle in degrees
}
Example #3
0
bool Rectangle::Intersects(const Vector2D& position) const {

    auto p = this->_transform.GetPosition();
    auto e = this->_half_extents;

    double rX = p.GetX();
    double rHalfWidth = e.GetX();
    double rLeft = rX - rHalfWidth;
    double rRight = rX + rHalfWidth;

    double rY = p.GetY();
    double rHalfHeight = e.GetY();
    double rTop = rY - rHalfHeight;
    double rBottom = rY + rHalfHeight;

    double pX = position.GetX();
    double pY = position.GetY();

    if(rLeft > pX) return false;
    if(rRight < pX) return false;
    if(rTop > pY) return false;
    if(rBottom < pY) return false;

    return true;
}
Example #4
0
void a2de::Sprite::SetScale(const Vector2D& scale) {
    double x = scale.GetX();
    double y = scale.GetY();
    if(x < 0.0) x = 0.0;
    if(y < 0.0) y = 0.0;
    _scaleDimensions = Vector2D(x, y);
    CalcCenterFrame();
}
Example #5
0
//========================================================================
void LinearTransform2D::Transform( Vector2D& result, const Vector2D& vector ) const
{
	Vector2D xComponent, yComponent;

	xComponent.Scale( xAxis, vector.GetX() );
	yComponent.Scale( yAxis, vector.GetY() );

	result.Add( xComponent, yComponent );
}
Example #6
0
void a2de::Sprite::SetCenter(const Vector2D& center) {
    int x = center.GetX();
    int y = center.GetY();
    if(x < 0) x = 0;
    if(x > _frameDimensions.GetX() * _scaleDimensions.GetX()) x = _frameDimensions.GetX() * _scaleDimensions.GetX();
    if(y < 0) y = 0;
    if(y > _frameDimensions.GetY() * _scaleDimensions.GetY()) y = _frameDimensions.GetY() * _scaleDimensions.GetY();
    _center = Vector2D(x, y);
}
Example #7
0
Bullet::Bullet(Vector2D pos, double angle)
{
	DEBUG_MSG("Constructing Bullet");

	m_turretAngle = angle;

	//Set positions and dimensions of sprites
	m_position = Vector2D((pos.GetX()) - 5, (pos.GetY()) - 2);

	m_destination.x = m_position.GetX();	
	m_destination.y = m_position.GetY();	
	m_destination.w = 10;
	m_destination.h = 6;
	m_speed = 200.0f;
}
Example #8
0
void Triangle::SetPosition(const Vector2D& position) {
    double deltaX = position.GetX() - GetX();
    double deltaY = position.GetY() - GetY();

    double aX = GetPointA().GetX() + deltaX;
    double bX = GetPointB().GetX() + deltaX;
    double cX = GetPointC().GetX() + deltaX;

    double aY = GetPointA().GetY() + deltaY;
    double bY = GetPointB().GetY() + deltaY;
    double cY = GetPointC().GetY() + deltaY;

    SetPoints(aX, aY, bX, bY, cX, cY);
    
    _position = Vector2D((aX + bX + cX) / 3.0, (aY + bY + cY) / 3.0);

}
Example #9
0
a2de::Matrix3x3 Matrix3x3::GetScaleMatrix(const Vector2D& scale) {
    return GetScaleMatrix(scale.GetX(), scale.GetY());

}
Example #10
0
a2de::Matrix3x3 Matrix3x3::GetTranslationMatrix(const Vector2D& pos) {
    return GetTranslationMatrix(pos.GetX(), pos.GetY());
}
Example #11
0
float Vector2D::DotProduct(Vector2D &Vector){
	float fResult;
	return fResult = (fx *Vector.GetX()) + (fy*Vector.GetY());
}
Example #12
0
void Sector::SetHalfExtents(const Vector2D& dimensions) {
    _half_extents = Vector2D((dimensions.GetX() < 0.0 ? 0.0 : dimensions.GetX()), (dimensions.GetY() < 0.0 ? 0.0 : dimensions.GetY()));
    _arc.SetHalfExtents(_half_extents);
}
Example #13
0
void Line::SetPosition(const Vector2D& position) {
    this->SetPointOne(GetPointOne().GetX() - position.GetX(), GetPointOne().GetY() - -position.GetY());
    this->SetPointTwo(GetPointTwo().GetX() - position.GetX(), GetPointTwo().GetY() - -position.GetY());
    CalculateLengthSquared();
    CalculateSlope();
    Shape::SetPosition(a2de::Vector2D(_extent_one.GetX() + _extent_two.GetX() / 2.0, _extent_one.GetY() + _extent_two.GetY() / 2.0));
}
float
Vector2D::dot(Vector2D v, Vector2D u)
{
	return (v.GetX()*u.GetX()) + (v.GetY()*u.GetY());
}