ArnieBoids  1.0.0
JOINT AI PROJECT
Bullet Class Reference

Bullet class. A simple bullet that moves in a direction for a lifetime. Dies if it hits something. More...

#include <Bullet.hpp>

Inheritance diagram for Bullet:
Collaboration diagram for Bullet:

Public Types

enum  Faction { PLAYER, ENEMY }
 Every bullet either belongs to the player or to an enemy. More...
 

Public Member Functions

 Bullet (sf::Vector2f const &position, sf::Vector2f const &direction, const float speed=10.f)
 
 ~Bullet ()
 
virtual void update ()
 Moves the bullet forward and checks if it has exceeded time to live. More...
 
bool isActive () const
 Is the bullet active? More...
 
void setActive (bool active)
 
int getDamage () const
 Gets the damage that the bullet will deal to something it hits. More...
 
Faction getFaction () const
 
void setFaction (Faction faction)
 

Protected Member Functions

float tickToSec (unsigned int ticks) const
 Ticks to seconds. More...
 

Protected Attributes

float speed_
 How far the bullet travels each update. More...
 
int damage_
 How much damage a bullet does. More...
 
unsigned int ticks_
 Ticks since bullet has spawned. More...
 
sf::Vector2f forward_
 The direction or heading of the bullet. More...
 
int lifeTime_
 The number of ticks that the bullet will remain alive for. More...
 
bool active_
 True if the bullet has been fired and hasn't collided with anything. More...
 
Faction faction_
 Will be PLAYER or ENEMY, depending on who fired it. More...
 

Detailed Description

Bullet class. A simple bullet that moves in a direction for a lifetime. Dies if it hits something.

Member Enumeration Documentation

Every bullet either belongs to the player or to an enemy.

Enumerator
PLAYER 
ENEMY 

Constructor & Destructor Documentation

Bullet::Bullet ( sf::Vector2f const &  position,
sf::Vector2f const &  direction,
const float  speed = 10.f 
)
Bullet::~Bullet ( )

Member Function Documentation

int Bullet::getDamage ( ) const

Gets the damage that the bullet will deal to something it hits.

Bullet::Faction Bullet::getFaction ( ) const
bool Bullet::isActive ( ) const

Is the bullet active?

void Bullet::setActive ( bool  active)
void Bullet::setFaction ( Faction  faction)

Here is the caller graph for this function:

float Bullet::tickToSec ( unsigned int  ticks) const
protected

Ticks to seconds.

Here is the caller graph for this function:

void Bullet::update ( )
virtual

Moves the bullet forward and checks if it has exceeded time to live.

Reimplemented in Missile.

Here is the call graph for this function:

Member Data Documentation

bool Bullet::active_
protected

True if the bullet has been fired and hasn't collided with anything.

int Bullet::damage_
protected

How much damage a bullet does.

Faction Bullet::faction_
protected

Will be PLAYER or ENEMY, depending on who fired it.

sf::Vector2f Bullet::forward_
protected

The direction or heading of the bullet.

int Bullet::lifeTime_
protected

The number of ticks that the bullet will remain alive for.

float Bullet::speed_
protected

How far the bullet travels each update.

unsigned int Bullet::ticks_
protected

Ticks since bullet has spawned.


The documentation for this class was generated from the following files: