Dragonfly 4.20
A text-based game engine
Public Member Functions | Private Member Functions | Private Attributes | List of all members
df::Particle Class Reference
Inheritance diagram for df::Particle:
Inheritance graph

Public Member Functions

 Particle (float size, int age, unsigned char opacity, unsigned char r, unsigned char g, unsigned char b)
 
 Particle (float size, int age, unsigned char opacity, Color color)
 
void setRGB (Color color)
 
void setRGB (unsigned char r, unsigned char g, unsigned char b)
 
void setAge (int new_age)
 
int getAge () const
 
int eventHandler (const Event *p_e) override
 
virtual int serialize (std::stringstream *p_ss, unsigned int attr=0) override
 
virtual int deserialize (std::stringstream *p_ss, unsigned int *p_a) override
 
- Public Member Functions inherited from df::Object
 Object ()
 
virtual ~Object ()
 
void setId (int new_id)
 
int getId () const
 
virtual void setType (std::string new_type)
 
std::string getType () const
 
virtual int setPosition (Vector new_position)
 
Vector getPosition () const
 
virtual int eventHandler (const Event *p_event)
 
bool isSolid () const
 
virtual int setSolidness (Solidness new_solid)
 
Solidness getSolidness () const
 
void setNoSoft (bool new_no_soft=true)
 
bool getNoSoft () const
 
virtual void setAvoidCollisions (bool new_avoid_collisions=true)
 
bool getAvoidCollisions () const
 
virtual int setAltitude (int new_altitude)
 
int getAltitude () const
 
void setSpeed (float speed)
 
float getSpeed () const
 
virtual void setDirection (Vector new_direction)
 
Vector getDirection () const
 
virtual void setVelocity (Vector velocity)
 
Vector getVelocity () const
 
virtual void setAcceleration (Vector new_acceleration)
 
Vector getAcceleration () const
 
void accelerate ()
 
Vector predictPosition ()
 
void pathTo (Vector position)
 
void pathTo (Object *p_o_target)
 
void moveTo (Vector new_position)
 
void doPathFollowing ()
 
int setVisible (bool new_visible=true)
 
virtual bool isVisible () const
 
virtual int setActive (bool new_active=true)
 
bool isActive () const
 
virtual void setBox (Box new_box)
 
Box getBox () const
 
int registerInterest (std::string event_type)
 
int unregisterInterest (std::string event_type)
 
int getEventCount () const
 
virtual int setSprite (std::string sprite_label)
 
virtual void setAnimation (Animation new_animation, bool set_box=true)
 
Animation getAnimation () const
 
virtual int draw ()
 
virtual int serialize (std::stringstream *p_ss, unsigned int attr=0)
 
virtual int deserialize (std::stringstream *p_ss, unsigned int *p_a=NULL)
 
bool isModified (enum ObjectAttribute attribute) const
 
bool isModified () const
 
virtual void setModified (unsigned int new_modified)
 
virtual unsigned int getModified () const
 
virtual void setShape (Shape new_shape)
 
Shape getShape () const
 
virtual void setFollowPath (bool new_follow_path=true)
 
bool getFollowPath () const
 
void setPath (Path new_path)
 
Path getPath () const
 
PathFindgetPathFind ()
 
std::string toString () const
 
bool operator== (const Object &o)
 
bool operator!= (const Object &o)
 

Private Member Functions

void init (float size, int age, unsigned char opacity, unsigned char r, unsigned char g, unsigned char b)
 

Private Attributes

int m_age
 

Additional Inherited Members

- Static Public Attributes inherited from df::Object
static int max_id
 

Constructor & Destructor Documentation

◆ Particle() [1/2]

df::Particle::Particle ( float  size,
int  age,
unsigned char  opacity,
unsigned char  r,
unsigned char  g,
unsigned char  b 
)

Create particle with size (pixels), age (in ticks), opacity (0-255) and rgb color.

◆ Particle() [2/2]

df::Particle::Particle ( float  size,
int  age,
unsigned char  opacity,
Color  color 
)

Create particle with size (pixels), age (in ticks), opacity (0-255) and Dragonfly color.

Member Function Documentation

◆ deserialize()

virtual int df::Particle::deserialize ( std::stringstream *  p_ss,
unsigned int *  p_a 
)
overridevirtual

Log warning if trying to deserialize particles.

Reimplemented from df::Object.

◆ eventHandler()

int df::Particle::eventHandler ( const Event p_e)
overridevirtual

Handle event (handles step to age and out delete).

Return 0 if ignored, else 1.

Reimplemented from df::Object.

Reimplemented in df::Precipitation.

◆ getAge()

int df::Particle::getAge ( ) const

Get age.

◆ serialize()

virtual int df::Particle::serialize ( std::stringstream *  p_ss,
unsigned int  attr = 0 
)
overridevirtual

Log warning if trying to serialize particles.

Reimplemented from df::Object.

◆ setAge()

void df::Particle::setAge ( int  new_age)

Set age.

◆ setRGB()

void df::Particle::setRGB ( Color  color)

Set colors.

Member Data Documentation

◆ m_age

int df::Particle::m_age
private

Age to live (in ticks).