ArnieBoids  1.0.0
JOINT AI PROJECT
Ship Class Referenceabstract

Base Ship class. Abstract class that inherits from sf::ConvexShape. Contains members common to all ships. More...

#include <Ship.hpp>

Inheritance diagram for Ship:
Collaboration diagram for Ship:

Public Member Functions

 Ship (thor::ParticleSystem &particleSystem, sf::Vector2f const &position, float maxSpeed, unsigned int health=1u)
 
 ~Ship ()
 
virtual void update ()
 Hides sf::Shape::update() More...
 
virtual void onCollide (Ship *other)=0
 
void takeDamage (unsigned int amount=1u)
 Reduces health by the specified amount. More...
 
bool isDead () const
 Returns true if health is zero. More...
 
void thrust ()
 Apply acceleration in direction of forward vector. More...
 
void brake ()
 Apply deceleration if thrust is present. More...
 
void turnLeft ()
 Turn ship left. More...
 
void turnRight ()
 Turn ship right. More...
 
bool trigger ()
 Attempt to fire, returns success. More...
 
void turnToward (sf::Vector2f const &direction)
 
sf::Vector2f getForward () const
 Returns forward direction of ship. More...
 
sf::Vector2f getVelocity () const
 Returns velocity. More...
 
void setRadarRange (float range)
 Radar radius accessors. More...
 
float getRadarRange () const
 
int getHealth () const
 Health accessors. More...
 
void addHealth (unsigned int health)
 
unsigned int getMaxHealth () const
 

Public Attributes

sf::RectangleShape debug_rect_
 

Protected Member Functions

void clampToMaxSpeed ()
 Clamps the length of the velocity_ vector to MAX_SPEED_. More...
 
float tickToSec (unsigned int ticks) const
 Ticks to seconds. More...
 
virtual void updateParticleEmitter ()
 

Protected Attributes

const float MAX_SPEED_
 Maximum length of velocity vector. More...
 
const unsigned int MAX_HEALTH_
 
float refireTime_
 
float coolDown_
 
unsigned int ticks_
 
sf::Vector2f velocity_
 Delta position per update. More...
 
sf::Vector2f accel_
 Delta velocity after update !velocity_ += accel_ in update! More...
 
int health_
 Current health. More...
 
sf::Vector2f forward_
 Unit vector for ship's heading. More...
 
float thrust_
 How fast the ship accelerates. More...
 
float turnSpeed_
 How fast (in degrees) the ship can turn. More...
 
float radarRange_
 Ship's radar radius. More...
 
thor::UniversalEmitter particleEmitter_
 Does nothing on it's own. Derived classes should play with this. More...
 
float particleAngleVariance_
 

Private Attributes

thor::Connection connection_
 The ship's connection to the Game's particle system. More...
 

Detailed Description

Base Ship class. Abstract class that inherits from sf::ConvexShape. Contains members common to all ships.

Constructor & Destructor Documentation

Ship::Ship ( thor::ParticleSystem &  particleSystem,
sf::Vector2f const &  position,
float  maxSpeed,
unsigned int  health = 1u 
)
Ship::~Ship ( )

Member Function Documentation

void Ship::addHealth ( unsigned int  health)

Here is the caller graph for this function:

void Ship::brake ( )

Apply deceleration if thrust is present.

Here is the caller graph for this function:

void Ship::clampToMaxSpeed ( )
protected

Clamps the length of the velocity_ vector to MAX_SPEED_.

Here is the caller graph for this function:

sf::Vector2f Ship::getForward ( ) const

Returns forward direction of ship.

Here is the caller graph for this function:

int Ship::getHealth ( ) const

Health accessors.

Here is the caller graph for this function:

unsigned int Ship::getMaxHealth ( ) const

Here is the caller graph for this function:

float Ship::getRadarRange ( ) const

Here is the caller graph for this function:

sf::Vector2f Ship::getVelocity ( ) const

Returns velocity.

Here is the caller graph for this function:

bool Ship::isDead ( ) const

Returns true if health is zero.

virtual void Ship::onCollide ( Ship other)
pure virtual

Implemented in Mothership, Asteroid, SwarmBoid, Player, and Predator.

void Ship::setRadarRange ( float  range)

Radar radius accessors.

void Ship::takeDamage ( unsigned int  amount = 1u)

Reduces health by the specified amount.

Here is the caller graph for this function:

void Ship::thrust ( )

Apply acceleration in direction of forward vector.

Here is the caller graph for this function:

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

Ticks to seconds.

Here is the caller graph for this function:

bool Ship::trigger ( )

Attempt to fire, returns success.

Here is the caller graph for this function:

void Ship::turnLeft ( )

Turn ship left.

Here is the caller graph for this function:

void Ship::turnRight ( )

Turn ship right.

Here is the caller graph for this function:

void Ship::turnToward ( sf::Vector2f const &  direction)

Turns toward a given direction

Here is the call graph for this function:

Here is the caller graph for this function:

void Ship::update ( )
virtual

Hides sf::Shape::update()

Reimplemented in Mothership, Asteroid, SwarmBoid, Player, and Predator.

Here is the call graph for this function:

Here is the caller graph for this function:

void Ship::updateParticleEmitter ( )
protectedvirtual

Reimplemented in Mothership.

Here is the caller graph for this function:

Member Data Documentation

sf::Vector2f Ship::accel_
protected

Delta velocity after update !velocity_ += accel_ in update!

thor::Connection Ship::connection_
private

The ship's connection to the Game's particle system.

float Ship::coolDown_
protected
sf::RectangleShape Ship::debug_rect_
sf::Vector2f Ship::forward_
protected

Unit vector for ship's heading.

int Ship::health_
protected

Current health.

const unsigned int Ship::MAX_HEALTH_
protected
const float Ship::MAX_SPEED_
protected

Maximum length of velocity vector.

float Ship::particleAngleVariance_
protected
thor::UniversalEmitter Ship::particleEmitter_
protected

Does nothing on it's own. Derived classes should play with this.

float Ship::radarRange_
protected

Ship's radar radius.

float Ship::refireTime_
protected
float Ship::thrust_
protected

How fast the ship accelerates.

unsigned int Ship::ticks_
protected
float Ship::turnSpeed_
protected

How fast (in degrees) the ship can turn.

sf::Vector2f Ship::velocity_
protected

Delta position per update.


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