Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Teddy::SpaceGame::Ship Class Reference

Ship. More...

#include <Ship.h>

Inheritance diagram for Teddy::SpaceGame::Ship:

Inheritance graph
[legend]
Collaboration diagram for Teddy::SpaceGame::Ship:

Collaboration graph
[legend]
List of all members.

Public Methods

 Ship (char *name, ShipType *ship_type, Root *root)
 Ship constructor. More...

ShipTypegetShipType ()
void setTarget (ModelInstance *mi, Vector offset=Vector(0, 0, 0))
ModelInstance * getTarget ()
void setTargetPosition ()
 Teleport instantly to target postion. Used to initialize wingmen position. More...

float getPitch () const
float getRoll () const
float getSpeed () const
virtual void tick ()
 Simulate one tick. More...

void controlPitchUp (bool apply)
 Ship has activated or deactivated pitch up control. More...

void controlPitchDown (bool apply)
 Ship has activated or deactivated pitch down control. More...

void controlRollLeft (bool apply)
 Ship has activated or deactivated roll left control. More...

void controlRollRight (bool apply)
 Ship has activated or deactivated roll right control. More...

void controlMoreSpeed (bool apply)
 Ship wants more speed. More...

void controlLessSpeed (bool apply)
 Ship wants less speed. More...

void controlStop (bool apply)
 Ship wants to stop. More...

void controlFireWeapon (bool apply)
 Ship wants to fire its weapon. More...

void stopSpeed ()
void stopPitch ()
void stopRoll ()
void collide ()
float getBrakeDistance () const
float getTargetDistance () const
float getPitchDistance ()
float getRollDistance ()
void trackTarget ()
virtual void applyControls (float age)
 Apply ship controls. More...


Protected Attributes

Rootroot
 Application root. More...

ShipTypeship_type
ModelInstance * target
 Ship navigation aimpoint. More...

Vector target_offset
 Aimpoint offset. More...

float prev_bullet_time
bool control_pitch_up
 True if pitch up key is pressed down. More...

bool control_pitch_down
 True if pitch down key is pressed down. More...

bool control_roll_left
 True if roll left key is pressed down. More...

bool control_roll_right
 True if roll right key is pressed down. More...

bool control_more_speed
 True if player wants more speed. More...

bool control_less_speed
 True if player wants less speed. More...

bool control_stop
 True if player wants to stop. More...

bool control_fire_weapon
 True if player wants to fire weapon. More...

bool active_pitch
 True if player is controlling pitch. More...

bool active_roll
 True if player is controlling roll. More...

float pitch_delta
float roll_delta
float pitch
 Current ship pitch delta. More...

float roll
 Current ship roll delta. More...

float speed
 Current ship speed. More...

float accel
 Current ship acceleration. More...

float pitch_distance
float roll_distance

Detailed Description

Ship.

Todo:
docs

Definition at line 47 of file Ship.h.


Constructor & Destructor Documentation

Teddy::SpaceGame::Ship::Ship char *    name,
ShipType   ship_type,
Root   root
 

Ship constructor.

Parameters:
name  Name for this Ship instance
ship_type  Type of this Ship

Definition at line 48 of file Ship.cpp.

References accel, active_pitch, active_roll, control_fire_weapon, control_less_speed, control_more_speed, control_pitch_down, control_pitch_up, control_roll_left, control_roll_right, control_stop, pitch, pitch_delta, roll, roll_delta, root, ship_type, speed, target, and target_offset.


Member Function Documentation

void Teddy::SpaceGame::Ship::applyControls float    age [virtual]
 

Apply ship controls.

Reimplemented in Teddy::SpaceGame::ComputerShip, and Teddy::SpaceGame::PlayerShip.

Definition at line 34 of file ShipControls.cpp.

References active_pitch, active_roll, pitch, pitch_delta, roll, roll_delta, ship_type, speed, and Teddy::SpaceGame::SimulatedInstance::tick_translation.

Referenced by tick().

void Teddy::SpaceGame::Ship::collide  
 

Definition at line 36 of file Ship.cpp.

References speed, and Teddy::SpaceGame::SimulatedInstance::tick_translation.

void Teddy::SpaceGame::Ship::controlFireWeapon bool    apply
 

Ship wants to fire its weapon.

Definition at line 231 of file ShipControls.cpp.

References control_fire_weapon.

void Teddy::SpaceGame::Ship::controlLessSpeed bool    apply
 

Ship wants less speed.

Definition at line 220 of file ShipControls.cpp.

References control_less_speed.

Referenced by stopSpeed(), and trackTarget().

void Teddy::SpaceGame::Ship::controlMoreSpeed bool    apply
 

Ship wants more speed.

Definition at line 214 of file ShipControls.cpp.

References control_more_speed.

Referenced by stopSpeed(), and trackTarget().

void Teddy::SpaceGame::Ship::controlPitchDown bool    apply
 

Ship has activated or deactivated pitch down control.

Definition at line 163 of file ShipControls.cpp.

References active_pitch, control_pitch_down, pitch_delta, and ship_type.

Referenced by stopPitch(), and trackTarget().

void Teddy::SpaceGame::Ship::controlPitchUp bool    apply
 

Ship has activated or deactivated pitch up control.

Definition at line 146 of file ShipControls.cpp.

References active_pitch, control_pitch_up, pitch_delta, and ship_type.

Referenced by stopPitch(), and trackTarget().

void Teddy::SpaceGame::Ship::controlRollLeft bool    apply
 

Ship has activated or deactivated roll left control.

Definition at line 197 of file ShipControls.cpp.

References active_roll, control_roll_right, roll_delta, and ship_type.

Referenced by stopRoll(), and trackTarget().

void Teddy::SpaceGame::Ship::controlRollRight bool    apply
 

Ship has activated or deactivated roll right control.

Definition at line 180 of file ShipControls.cpp.

References active_roll, control_roll_left, roll_delta, and ship_type.

Referenced by stopRoll(), and trackTarget().

void Teddy::SpaceGame::Ship::controlStop bool    apply
 

Ship wants to stop.

Definition at line 226 of file ShipControls.cpp.

References control_stop.

float Teddy::SpaceGame::Ship::getBrakeDistance   const
 

Definition at line 135 of file Ship.cpp.

References ship_type, and speed.

float Teddy::SpaceGame::Ship::getPitch   const
 

Definition at line 368 of file Ship.cpp.

References pitch.

float Teddy::SpaceGame::Ship::getPitchDistance   [inline]
 

Definition at line 82 of file Ship.h.

References pitch_distance.

float Teddy::SpaceGame::Ship::getRoll   const
 

Definition at line 372 of file Ship.cpp.

References roll.

float Teddy::SpaceGame::Ship::getRollDistance   [inline]
 

Definition at line 83 of file Ship.h.

References roll_distance.

ShipType * Teddy::SpaceGame::Ship::getShipType  
 

Definition at line 337 of file Ship.cpp.

References ship_type.

float Teddy::SpaceGame::Ship::getSpeed   const
 

Definition at line 376 of file Ship.cpp.

References speed.

ModelInstance * Teddy::SpaceGame::Ship::getTarget  
 

Definition at line 364 of file Ship.cpp.

References target.

float Teddy::SpaceGame::Ship::getTargetDistance   const
 

Definition at line 120 of file Ship.cpp.

References target.

Referenced by trackTarget().

void Teddy::SpaceGame::Ship::setTarget ModelInstance *    mi,
Vector    offset = Vector(0,0,0)
 

Definition at line 341 of file Ship.cpp.

References target, and target_offset.

void Teddy::SpaceGame::Ship::setTargetPosition  
 

Teleport instantly to target postion. Used to initialize wingmen position.

Definition at line 348 of file Ship.cpp.

References target, and target_offset.

void Teddy::SpaceGame::Ship::stopPitch  
 

Definition at line 95 of file Ship.cpp.

References controlPitchDown(), controlPitchUp(), and pitch.

Referenced by trackTarget().

void Teddy::SpaceGame::Ship::stopRoll  
 

Definition at line 106 of file Ship.cpp.

References controlRollLeft(), controlRollRight(), and roll.

Referenced by trackTarget().

void Teddy::SpaceGame::Ship::stopSpeed  
 

Definition at line 84 of file Ship.cpp.

References controlLessSpeed(), controlMoreSpeed(), and speed.

Referenced by trackTarget().

void Teddy::SpaceGame::Ship::tick   [virtual]
 

Simulate one tick.

Reimplemented from Teddy::SpaceGame::SimulatedInstance.

Definition at line 76 of file Ship.cpp.

References applyControls().

void Teddy::SpaceGame::Ship::trackTarget  
 

Tactics:

If V: > 0.5 -> forward If V: < 0.5 -> backward

If U: < 0 -> pitch up ; do only if If U: > 0 -> pitch down ; fabs(U) > fabs(R)

If R: > 0 -> roll right If R: < 0 -> roll left

Definition at line 155 of file Ship.cpp.

References controlLessSpeed(), controlMoreSpeed(), controlPitchDown(), controlPitchUp(), controlRollLeft(), controlRollRight(), getTargetDistance(), pitch, pitch_distance, roll, roll_distance, ship_type, Teddy::SpaceGame::SimulatedInstance::SimulatedInstance(), speed, stopPitch(), stopRoll(), stopSpeed(), target, and target_offset.

Referenced by Teddy::SpaceGame::ComputerShip::applyControls().


Member Data Documentation

float Teddy::SpaceGame::Ship::accel [protected]
 

Current ship acceleration.

Definition at line 114 of file Ship.h.

Referenced by Ship().

bool Teddy::SpaceGame::Ship::active_pitch [protected]
 

True if player is controlling pitch.

Definition at line 106 of file Ship.h.

Referenced by applyControls(), controlPitchDown(), controlPitchUp(), and Ship().

bool Teddy::SpaceGame::Ship::active_roll [protected]
 

True if player is controlling roll.

Definition at line 107 of file Ship.h.

Referenced by applyControls(), controlRollLeft(), controlRollRight(), and Ship().

bool Teddy::SpaceGame::Ship::control_fire_weapon [protected]
 

True if player wants to fire weapon.

Definition at line 105 of file Ship.h.

Referenced by controlFireWeapon(), and Ship().

bool Teddy::SpaceGame::Ship::control_less_speed [protected]
 

True if player wants less speed.

Definition at line 103 of file Ship.h.

Referenced by controlLessSpeed(), and Ship().

bool Teddy::SpaceGame::Ship::control_more_speed [protected]
 

True if player wants more speed.

Definition at line 102 of file Ship.h.

Referenced by controlMoreSpeed(), and Ship().

bool Teddy::SpaceGame::Ship::control_pitch_down [protected]
 

True if pitch down key is pressed down.

Definition at line 99 of file Ship.h.

Referenced by controlPitchDown(), and Ship().

bool Teddy::SpaceGame::Ship::control_pitch_up [protected]
 

True if pitch up key is pressed down.

Definition at line 98 of file Ship.h.

Referenced by controlPitchUp(), and Ship().

bool Teddy::SpaceGame::Ship::control_roll_left [protected]
 

True if roll left key is pressed down.

Definition at line 100 of file Ship.h.

Referenced by controlRollRight(), and Ship().

bool Teddy::SpaceGame::Ship::control_roll_right [protected]
 

True if roll right key is pressed down.

Definition at line 101 of file Ship.h.

Referenced by controlRollLeft(), and Ship().

bool Teddy::SpaceGame::Ship::control_stop [protected]
 

True if player wants to stop.

Definition at line 104 of file Ship.h.

Referenced by controlStop(), and Ship().

float Teddy::SpaceGame::Ship::pitch [protected]
 

Current ship pitch delta.

Definition at line 111 of file Ship.h.

Referenced by applyControls(), getPitch(), Ship(), stopPitch(), and trackTarget().

float Teddy::SpaceGame::Ship::pitch_delta [protected]
 

Definition at line 109 of file Ship.h.

Referenced by applyControls(), controlPitchDown(), controlPitchUp(), and Ship().

float Teddy::SpaceGame::Ship::pitch_distance [protected]
 

Definition at line 115 of file Ship.h.

Referenced by getPitchDistance(), and trackTarget().

float Teddy::SpaceGame::Ship::prev_bullet_time [protected]
 

Definition at line 96 of file Ship.h.

Referenced by Teddy::SpaceGame::PlayerShip::applyControls(), and Teddy::SpaceGame::PlayerShip::PlayerShip().

float Teddy::SpaceGame::Ship::roll [protected]
 

Current ship roll delta.

Definition at line 112 of file Ship.h.

Referenced by applyControls(), getRoll(), Ship(), stopRoll(), and trackTarget().

float Teddy::SpaceGame::Ship::roll_delta [protected]
 

Definition at line 110 of file Ship.h.

Referenced by applyControls(), controlRollLeft(), controlRollRight(), and Ship().

float Teddy::SpaceGame::Ship::roll_distance [protected]
 

Definition at line 116 of file Ship.h.

Referenced by getRollDistance(), and trackTarget().

Root* Teddy::SpaceGame::Ship::root [protected]
 

Application root.

Definition at line 92 of file Ship.h.

Referenced by Teddy::SpaceGame::PlayerShip::applyControls(), Teddy::SpaceGame::PlayerShip::PlayerShip(), and Ship().

ShipType* Teddy::SpaceGame::Ship::ship_type [protected]
 

Definition at line 93 of file Ship.h.

Referenced by applyControls(), controlPitchDown(), controlPitchUp(), controlRollLeft(), controlRollRight(), getBrakeDistance(), getShipType(), Ship(), and trackTarget().

float Teddy::SpaceGame::Ship::speed [protected]
 

Current ship speed.

Definition at line 113 of file Ship.h.

Referenced by applyControls(), collide(), getBrakeDistance(), getSpeed(), Ship(), stopSpeed(), and trackTarget().

ModelInstance* Teddy::SpaceGame::Ship::target [protected]
 

Ship navigation aimpoint.

Definition at line 94 of file Ship.h.

Referenced by getTarget(), getTargetDistance(), setTarget(), setTargetPosition(), Ship(), and trackTarget().

Vector Teddy::SpaceGame::Ship::target_offset [protected]
 

Aimpoint offset.

Definition at line 95 of file Ship.h.

Referenced by setTarget(), setTargetPosition(), Ship(), and trackTarget().


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