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

Public Member Functions

 Shape ()
 
void setSize (float new_size)
 
float getSize () const
 
void setType (ShapeType new_type)
 
ShapeType getType () const
 
void setColor (Color new_color)
 
void setColor (unsigned char r, unsigned char g, unsigned char b)
 
Color getColor () const
 
void setOpacity (unsigned char new_opacity)
 
unsigned char getOpacity () const
 
void draw (Vector world_pos)
 
int serialize (std::stringstream *p_ss) const
 
int deserialize (std::stringstream *p_ss)
 
bool operator== (const Shape &s)
 
bool operator!= (const Shape &s)
 
std::string toString () const
 

Private Attributes

Color m_color
 
unsigned char m_r
 
unsigned char m_g
 
unsigned char m_b
 
ShapeType m_type
 
float m_size
 
unsigned char m_opacity
 

Constructor & Destructor Documentation

◆ Shape()

df::Shape::Shape ( )

Default is Circle, df::WHITE, size 1 character.

Member Function Documentation

◆ draw()

void df::Shape::draw ( Vector  world_pos)

Draw self at given world position.

◆ getColor()

Color df::Shape::getColor ( ) const

Get color. Returns Dragonfly Color.

◆ getOpacity()

unsigned char df::Shape::getOpacity ( ) const

Get opacity (0 is transparent, 255 is opaque).

◆ getSize()

float df::Shape::getSize ( ) const

Get size (in pixels).

◆ getType()

ShapeType df::Shape::getType ( ) const

Get type.

◆ operator==()

bool df::Shape::operator== ( const Shape s)

Compare two Shapes.

◆ setColor() [1/2]

void df::Shape::setColor ( Color  new_color)

Set color, where input is Dragonfly Color.

◆ setColor() [2/2]

void df::Shape::setColor ( unsigned char  r,
unsigned char  g,
unsigned char  b 
)

Set color, where input is RGB.

◆ setOpacity()

void df::Shape::setOpacity ( unsigned char  new_opacity)

Set opacity (0 is transparent, 255 is opaque).

◆ setSize()

void df::Shape::setSize ( float  new_size)

Set size (in pixels).

◆ setType()

void df::Shape::setType ( ShapeType  new_type)

Set type.

Member Data Documentation

◆ m_b

unsigned char df::Shape::m_b
private

RGB colors used if color is CUSTOM.

◆ m_color

Color df::Shape::m_color
private

Shape color.

◆ m_opacity

unsigned char df::Shape::m_opacity
private

Opacity (transparent) 0 to 255 (opaque).

◆ m_size

float df::Shape::m_size
private

Radius size (in pixels).

◆ m_type

ShapeType df::Shape::m_type
private

Type of shape.