#include <air_attack.h>
Inheritance diagram for Plane:
Public Member Functions | |
Plane (AirAttackConfig &cfg) | |
void | Shoot (double speed, Point2i &target) |
void | Draw () |
void | Refresh () |
Private Member Functions | |
bool | OnTopOfTarget () const |
int | GetDirection () const |
void | DropBomb () |
Private Attributes | |
uint | nb_dropped_bombs |
Obus * | last_dropped_bomb |
int | obus_dx |
int | obus_dy |
Sprite * | image |
int | cible_x |
int | distance_to_release |
AirAttackConfig & | cfg |
Definition at line 47 of file air_attack.h.
Plane::Plane | ( | AirAttackConfig & | cfg | ) |
Definition at line 51 of file air_attack.cpp.
00051 : 00052 PhysicalObj("air_attack_plane"), 00053 cfg(p_cfg) 00054 { 00055 SetCollisionModel(true, false, false); 00056 00057 image = resource_manager.LoadSprite(weapons_res_profile, "air_attack_plane"); 00058 SetSize(image->GetSize()); 00059 obus_dx = 100; 00060 obus_dy = GetY() + GetHeight(); 00061 }
Here is the call graph for this function:
void Plane::Draw | ( | ) | [virtual] |
Implements PhysicalObj.
Definition at line 140 of file air_attack.cpp.
00141 { 00142 if (IsGhost()) return; 00143 image->Draw(GetPosition()); 00144 }
Here is the call graph for this function:
void Plane::DropBomb | ( | ) | [private] |
Definition at line 95 of file air_attack.cpp.
00096 { 00097 Obus * instance = new Obus(cfg); 00098 instance->SetXY(Point2i(GetX(), obus_dy) ); 00099 00100 Point2d speed_vector; 00101 GetSpeedXY(speed_vector); 00102 00103 int fx = randomSync.GetLong(FORCE_X_MIN, FORCE_X_MAX); 00104 fx *= GetDirection(); 00105 int fy = randomSync.GetLong(FORCE_Y_MIN, FORCE_Y_MAX); 00106 00107 speed_vector.SetValues(speed_vector.x + fx/30.0, speed_vector.y + fy/30.0); 00108 instance->SetSpeedXY(speed_vector); 00109 00110 lst_objects.AddObject(instance); 00111 00112 camera.FollowObject(instance, true, true); 00113 00114 last_dropped_bomb = instance; 00115 nb_dropped_bombs++; 00116 }
Here is the call graph for this function:
Here is the caller graph for this function:
int Plane::GetDirection | ( | ) | const [private] |
Definition at line 133 of file air_attack.cpp.
00134 { 00135 float x,y; 00136 image->GetScaleFactors(x,y); 00137 return (x<0)?-1:1; 00138 }
Here is the call graph for this function:
Here is the caller graph for this function:
bool Plane::OnTopOfTarget | ( | ) | const [private] |
Definition at line 146 of file air_attack.cpp.
00147 { 00148 if (GetDirection() == 1) 00149 return (cible_x <= GetX() + distance_to_release); 00150 else 00151 return (GetX() - (int)image->GetWidth() + obus_dx - distance_to_release <= cible_x); 00152 }
Here is the call graph for this function:
Here is the caller graph for this function:
void Plane::Refresh | ( | ) | [virtual] |
Implements PhysicalObj.
Definition at line 118 of file air_attack.cpp.
00119 { 00120 UpdatePosition(); 00121 image->Update(); 00122 // First shoot !! 00123 if ( OnTopOfTarget() && nb_dropped_bombs == 0) { 00124 camera.StopFollowingObj(this); 00125 DropBomb(); 00126 } else if (nb_dropped_bombs > 0 && nb_dropped_bombs < cfg.nbr_obus) { 00127 // Get the last rocket and check the position to be sure to not collide with it 00128 if ( last_dropped_bomb->GetY() > GetY()+GetHeight()+10 ) 00129 DropBomb(); 00130 } 00131 }
Here is the call graph for this function:
void Plane::Shoot | ( | double | speed, | |
Point2i & | target | |||
) |
Definition at line 63 of file air_attack.cpp.
00064 { 00065 nb_dropped_bombs = 0; 00066 last_dropped_bomb = NULL; 00067 00068 Point2d speed_vector ; 00069 int dir = ActiveCharacter().GetDirection(); 00070 cible_x = target.x; 00071 SetY(0); 00072 distance_to_release =(int)(speed * sqrt(2 * (GetY() + target.y))); 00073 00074 image->Scale(dir, 1); 00075 00076 if (dir == 1) { 00077 speed_vector.SetValues(speed, 0); 00078 SetX(-image->GetWidth() + 1); 00079 //distance_to_release -= obus_dx; 00080 if(distance_to_release > cible_x) distance_to_release=0; 00081 } else { 00082 speed_vector.SetValues(-speed, 0) ; 00083 SetX(world.GetWidth() - 1); 00084 //distance_to_release += obus_dx; 00085 if(distance_to_release > (world.GetWidth()-cible_x - obus_dx)) distance_to_release=0; 00086 } 00087 00088 SetSpeedXY (speed_vector); 00089 00090 camera.FollowObject(this, true, true); 00091 00092 lst_objects.AddObject(this); 00093 }
Here is the call graph for this function:
Here is the caller graph for this function:
AirAttackConfig& Plane::cfg [private] |
Definition at line 58 of file air_attack.h.
int Plane::cible_x [private] |
Definition at line 56 of file air_attack.h.
int Plane::distance_to_release [private] |
Definition at line 57 of file air_attack.h.
Sprite* Plane::image [private] |
Definition at line 54 of file air_attack.h.
Obus* Plane::last_dropped_bomb [private] |
Definition at line 51 of file air_attack.h.
uint Plane::nb_dropped_bombs [private] |
Definition at line 50 of file air_attack.h.
int Plane::obus_dx [private] |
Definition at line 53 of file air_attack.h.
int Plane::obus_dy [private] |
Definition at line 53 of file air_attack.h.