Dragonfly  4.4
A text-based game engine
Public Member Functions | Private Attributes | List of all members
df::Vector Class Reference

Public Member Functions

 Vector (float init_x, float init_y)
 Vector ()
float getX () const
void setX (float new_x)
float getY () const
void setY (float new_y)
void setXY (float new_x, float new_y)
void normalize ()
void scale (float s)
float getMagnitude () const
bool operator== (const Vector &other) const
bool operator!= (const Vector &other) const
Vectoroperator+= (const Vector &other)
Vector operator+ (const Vector &other) const
Vector operator- (const Vector &other) const
bool operator! () const

Private Attributes

float m_x
float m_y

Constructor & Destructor Documentation

df::Vector::Vector ( float  init_x,
float  init_y 

Create Vector with (x,y).

df::Vector::Vector ( )

Default is (0,0).

Member Function Documentation

float df::Vector::getMagnitude ( ) const

Return magnitude.

float df::Vector::getX ( ) const

Get horizontal component.

float df::Vector::getY ( ) const

Get vertical component.

void df::Vector::normalize ( )

Normalize vector.

bool df::Vector::operator! ( ) const

Test if (0,0).

bool df::Vector::operator!= ( const Vector other) const

Compare Vector.

Vector df::Vector::operator+ ( const Vector other) const

Add Vector.

Vector& df::Vector::operator+= ( const Vector other)

Add other Vector to this one.

Vector df::Vector::operator- ( const Vector other) const

Subtract Vector.

bool df::Vector::operator== ( const Vector other) const

Compare Vector.

void df::Vector::scale ( float  s)

Scale vector.

void df::Vector::setX ( float  new_x)

Set horizontal component.

void df::Vector::setXY ( float  new_x,
float  new_y 

Set horizizontal & vertical.

void df::Vector::setY ( float  new_y)

Set vertical component.

Member Data Documentation

float df::Vector::m_x

Horizontal component.

float df::Vector::m_y

Vertical component.