1 /****************************************************************************************** 2 * 3 * HighNoon - Duell im All 4 * Copyright (c) 2005, 2006 Patrick Gerdsmeier <patrick@gerdsmeier.net> 5 * 6 * "shoot.hpp" 7 * 8 * Explosion - Small Class for an Explosion 9 * 10 * Shoot - Main Class for a Shoot. Contains it's Explosion 11 * 12 * Lasers - Normal Shoot 13 * 14 * Cluster - Cluster Shoot. If it explodes (Timeout or Hit) it will release 15 * more Shoots 16 * 17 * Heavy - Low Gravity and high strength 18 * 19 * Funghi - Explodes and destroys in a wide-range 20 * 21 * 22 * 23 * This program is free software; you can redistribute it and/or modify 24 * it under the terms of the GNU General Public License as published by 25 * the Free Software Foundation; either version 2, or (at your option) 26 * any later version. 27 * 28 * This program is distributed in the hope that it will be useful, 29 * but WITHOUT ANY WARRANTY; without even the implied warranty of 30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 31 * GNU General Public License for more details. 32 * 33 * You should have received a copy of the GNU General Public License 34 * along with this program; if not, write to the Free Software 35 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 36 * 37 ******************************************************************************************/ 38 39 #ifndef __SHOOT_HPP__ 40 #define __SHOOT_HPP__ 41 42 #include "vector_2.hpp" 43 44 #include "constants.hpp" 45 #include "graphics.hpp" 46 #include "galaxy.hpp" 47 48 class Galaxy; 49 class Extra; 50 51 /************************************************************************ 52 * * 53 * Explosion * 54 * * 55 ************************************************************************/ 56 class Explosion : public Spaceobject 57 { 58 public: 59 Explosion( double x=0, double y=0 ); 60 61 ~Explosion(); 62 63 bool is_active() const; 64 65 void activate( double x, double y ); 66 67 bool check_collision( double x, double y, double width, bool spacing=false ); 68 69 void draw(); 70 71 void hit( Spaceobject *object ); 72 73 private: 74 bool exploding; 75 Sprite *explosion_sprite; 76 77 void calculate_ShootPath( Vector_2 start, Vector_2 direction, Galaxy *galaxy ); 78 }; 79 80 /************************************************************************ 81 * * 82 * Shoot * 83 * * 84 ************************************************************************/ 85 class Shoot : public Spaceobject 86 { 87 public: 88 Shoot( double x=0, double y=0 ); 89 90 ~Shoot(); 91 92 virtual bool is_active() const; 93 94 bool will_be_a_Hit( int player_id, double factor, Vector_2 start, Vector_2 direction, Galaxy *galaxy ); 95 96 void activate( Vector_2 start, Vector_2 vector ); 97 98 virtual void reset(); 99 100 virtual void destroy(); 101 102 virtual bool move( Galaxy *galaxy ); 103 104 virtual bool has_Extra_collision( Extra *extra ); 105 106 virtual bool check_collision( double x, double y, double width, bool spacing=false ); 107 108 virtual void draw(); 109 110 void draw_hint( Vector_2 start, Vector_2 direction, Galaxy *galaxy ); 111 112 virtual void hit( Spaceobject *object ); 113 114 protected: 115 bool is_exploding; 116 int moving_time; 117 Vector_2 last_shootPos; 118 int pre_calculated_Steps; 119 120 struct { 121 int x, y; 122 } pre_calculated_Pos[MAXPRECALC]; 123 124 Explosion *explosion; 125 126 void calculate_ShootPath( Vector_2 start, Vector_2 direction, Galaxy *galaxy ); 127 }; 128 129 /************************************************************************ 130 * * 131 * Laser * 132 * * 133 ************************************************************************/ 134 class Laser : public Shoot 135 { 136 public: 137 Laser( double x=0, double y=0 ); 138 139 ~Laser(); 140 141 bool is_active() const; 142 reset()143 void reset() {}; 144 145 void destroy(); 146 147 bool move( Galaxy *galaxy ); 148 149 bool has_Extra_collision( Extra *extra ); 150 151 bool check_collision( double x, double y, double width, bool spacing=false ); 152 153 void draw(); 154 155 void hit( Spaceobject *object ); 156 157 private: 158 Sprite *laser_sprite, 159 *laserback_sprite, 160 *laserbackk_sprite; 161 162 }; 163 164 /************************************************************************ 165 * * 166 * Heavy * 167 * * 168 ************************************************************************/ 169 class Heavy : public Shoot 170 { 171 public: 172 Heavy( double x=0, double y=0 ); 173 174 ~Heavy(); 175 176 bool is_active() const; 177 reset()178 void reset() {}; 179 180 void destroy(); 181 182 bool move( Galaxy *galaxy ); 183 184 bool has_Extra_collision( Extra *extra ); 185 186 bool check_collision( double x, double y, double width, bool spacing=false ); 187 188 void draw(); 189 190 void hit( Spaceobject *object ); 191 192 private: 193 Sprite *heavy_sprite, 194 *heavyback_sprite, 195 *heavybackk_sprite; 196 197 }; 198 199 /************************************************************************ 200 * * 201 * Cluster * 202 * * 203 ************************************************************************/ 204 class Cluster : public Shoot 205 { 206 public: 207 Cluster( double x=0, double y=0 ); 208 209 ~Cluster(); 210 211 bool is_active() const; 212 213 void reset(); 214 215 void destroy(); 216 217 bool move( Galaxy *galaxy ); 218 219 bool has_Extra_collision( Extra *extra ); 220 221 bool check_collision( double x, double y, double width, bool spacing=false ); 222 223 void draw(); 224 225 void hit( Spaceobject *object ); 226 227 private: 228 bool lasers_active; 229 bool destroyed; 230 int laser_hits; 231 232 Sprite *cluster_sprite, 233 *clusterback_sprite, 234 *clusterbackk_sprite; 235 Laser *lasers; 236 237 }; 238 239 #endif 240