ArnieBoids  1.0.0
JOINT AI PROJECT
Missile Class Reference

#include <Missile.hpp>

Inheritance diagram for Missile:
Collaboration diagram for Missile:

Public Member Functions

 Missile (thor::ParticleSystem &particleSystem, std::function< void()> destructCallback, const Ship *const target, sf::Vector2f const &position, sf::Vector2f const &direction, const float maxSpeed=4.f, const float acceleration=0.1f, const float turnSpeed=2.f)
 
 ~Missile ()
 Disconnects emitter from particle system and invokes destructCallback_. More...
 
virtual void update () override
 Turns to face target while thrusting forward. More...
 
void setForward (sf::Vector2f const &direction)
 
- Public Member Functions inherited from Bullet
 Bullet (sf::Vector2f const &position, sf::Vector2f const &direction, const float speed=10.f)
 
 ~Bullet ()
 
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

void updateParticleEmitter ()
 
- Protected Member Functions inherited from Bullet
float tickToSec (unsigned int ticks) const
 Ticks to seconds. More...
 

Protected Attributes

const Ship *const TARGET_
 Ship to be tracked. More...
 
const float MAX_SPEED_
 Maximum speed of the missile. Higher value == larger turning circle. More...
 
const float ACCELERATION_
 How fast (per tick) the missile accelerates. More...
 
const float TURN_SPEED_
 Has quickly the missile can turn. Higher value == tighter turning circle. More...
 
bool isAccelerating_
 True if the missile has yet to reach max speed. More...
 
thor::UniversalEmitter particleEmitter_
 Emitter for creating particles. More...
 
- Protected Attributes inherited from Bullet
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...
 

Private Attributes

thor::Connection connection_
 Connection of emitter to particle system. More...
 
const std::function< void()> destructCallback_
 Used to notify firing ship that this missile has exploded. More...
 

Additional Inherited Members

- Public Types inherited from Bullet
enum  Faction { PLAYER, ENEMY }
 Every bullet either belongs to the player or to an enemy. More...
 

Constructor & Destructor Documentation

Missile::Missile ( thor::ParticleSystem &  particleSystem,
std::function< void()>  destructCallback,
const Ship *const  target,
sf::Vector2f const &  position,
sf::Vector2f const &  direction,
const float  maxSpeed = 4.f,
const float  acceleration = 0.1f,
const float  turnSpeed = 2.f 
)
Parameters
particleSystemThe particle system to connect the Missile's emitter to
destructCallbackCalled when the missile is destroyed. See Missile::~Missile()
targetThe target for the missile
positionInitial position
directionLaunch direction
Missile::~Missile ( )

Disconnects emitter from particle system and invokes destructCallback_.

Member Function Documentation

void Missile::setForward ( sf::Vector2f const &  direction)
void Missile::update ( )
overridevirtual

Turns to face target while thrusting forward.

Reimplemented from Bullet.

Here is the call graph for this function:

void Missile::updateParticleEmitter ( )
protected

Here is the caller graph for this function:

Member Data Documentation

const float Missile::ACCELERATION_
protected

How fast (per tick) the missile accelerates.

thor::Connection Missile::connection_
private

Connection of emitter to particle system.

const std::function<void()> Missile::destructCallback_
private

Used to notify firing ship that this missile has exploded.

bool Missile::isAccelerating_
protected

True if the missile has yet to reach max speed.

const float Missile::MAX_SPEED_
protected

Maximum speed of the missile. Higher value == larger turning circle.

thor::UniversalEmitter Missile::particleEmitter_
protected

Emitter for creating particles.

const Ship* const Missile::TARGET_
protected

Ship to be tracked.

const float Missile::TURN_SPEED_
protected

Has quickly the missile can turn. Higher value == tighter turning circle.


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