![]() |
Dragonfly 4.22
A text-based game engine
|
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 |
| Vector & | operator+= (const Vector &other) |
| Vector | operator+ (const Vector &other) const |
| Vector | operator- (const Vector &other) const |
| bool | operator! () const |
| std::string | toString () const |
| int | serialize (std::stringstream *p_ss) const |
| int | deserialize (std::stringstream *p_ss) |
Private Attributes | |
| float | m_x |
| float | m_y |
| df::Vector::Vector | ( | float | init_x, |
| float | init_y | ||
| ) |
Create Vector with (x,y).
| df::Vector::Vector | ( | ) |
Default is (0,0).
| int df::Vector::deserialize | ( | std::stringstream * | p_ss | ) |
Deserialize attributes from stream.
Return 0 if ok, else -1.
| 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.
| void df::Vector::scale | ( | float | s | ) |
Scale vector.
| int df::Vector::serialize | ( | std::stringstream * | p_ss | ) | const |
Serialize attributes to stream.
Return 0 if ok, else -1.
| 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.
| std::string df::Vector::toString | ( | ) | const |
Return attributes as string.
|
private |
Horizontal component.
|
private |
Vertical component.