src/badguy/badguy.hpp

Go to the documentation of this file.
00001 //  SuperTux
00002 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
00003 //
00004 //  This program is free software: you can redistribute it and/or modify
00005 //  it under the terms of the GNU General Public License as published by
00006 //  the Free Software Foundation, either version 3 of the License, or
00007 //  (at your option) any later version.
00008 //
00009 //  This program is distributed in the hope that it will be useful,
00010 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 //  GNU General Public License for more details.
00013 //
00014 //  You should have received a copy of the GNU General Public License
00015 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 
00017 #ifndef HEADER_SUPERTUX_BADGUY_BADGUY_HPP
00018 #define HEADER_SUPERTUX_BADGUY_BADGUY_HPP
00019 
00020 #include "object/moving_sprite.hpp"
00021 #include "supertux/direction.hpp"
00022 #include "supertux/physic.hpp"
00023 #include "supertux/timer.hpp"
00024 
00025 class Player;
00026 class Bullet;
00027 
00029 class BadGuy : public MovingSprite
00030 {
00031 public:
00032   BadGuy(const Vector& pos, const std::string& sprite_name, int layer = LAYER_OBJECTS);
00033   BadGuy(const Vector& pos, Direction direction, const std::string& sprite_name, int layer = LAYER_OBJECTS);
00034   BadGuy(const Reader& reader, const std::string& sprite_name, int layer = LAYER_OBJECTS);
00035 
00038   virtual void draw(DrawingContext& context);
00039 
00042   virtual void update(float elapsed_time);
00043 
00047   virtual HitResponse collision(GameObject& other, const CollisionHit& hit);
00048 
00051   virtual void collision_tile(uint32_t tile_attributes);
00052 
00055   virtual void kill_fall();
00056   
00058   virtual void run_dead_script();
00059 
00062   virtual bool can_break()
00063   {
00064     return false;
00065   }
00066 
00067   Vector get_start_position() const
00068   {
00069     return start_position;
00070   }
00071 
00072   void set_start_position(const Vector& vec)
00073   {
00074     start_position = vec;
00075   }
00076 
00078   virtual void ignite();
00079 
00081   virtual void extinguish();
00082 
00084   virtual bool is_flammable() const;
00085 
00087   bool is_ignited() const;
00088 
00090   virtual void freeze();
00091 
00093   virtual void unfreeze();
00094 
00095   virtual bool is_freezable() const;
00096 
00097   bool is_frozen() const;
00098 
00099 protected:
00100   enum State {
00101     STATE_INIT,
00102     STATE_INACTIVE,
00103     STATE_ACTIVE,
00104     STATE_SQUISHED,
00105     STATE_FALLING
00106   };
00107 
00108 protected:
00110   virtual HitResponse collision_player(Player& player, const CollisionHit& hit);
00111 
00113   virtual void collision_solid(const CollisionHit& hit);
00114 
00116   virtual HitResponse collision_badguy(BadGuy& other, const CollisionHit& hit);
00117 
00121   virtual bool collision_squished(GameObject& object);
00122 
00124   virtual HitResponse collision_bullet(Bullet& bullet, const CollisionHit& hit);
00125 
00127   virtual void active_update(float elapsed_time);
00128 
00130   virtual void inactive_update(float elapsed_time);
00131 
00133   virtual void initialize();
00134   
00138   virtual void activate();
00139 
00141   virtual void deactivate();
00142 
00143   void kill_squished(GameObject& object);
00144 
00145   void set_state(State state);
00146   State get_state() const
00147   { return state; }
00148 
00149   bool check_state_timer() {
00150     return state_timer.check();
00151   }
00152 
00154   Player* get_nearest_player();
00155 
00158   bool is_offscreen();
00159 
00162   bool might_fall(int height = 1);
00163 
00165   Direction str2dir( std::string dir_str );
00166 
00171   void update_on_ground_flag(const CollisionHit& hit);
00172 
00176   bool on_ground();
00177 
00181   Vector get_floor_normal();
00182 
00185   bool is_active();
00186 
00188   void set_colgroup_active(CollisionGroup group); 
00189 
00190 private:
00191   void try_activate();
00192 
00193 protected:
00194   Physic physic;
00195 
00196 public:  
00199   bool countMe;
00200 
00201 protected:
00203   bool is_initialized; 
00204 
00205   Vector start_position;
00206 
00208   Direction dir;
00209 
00211   Direction start_dir;
00212 
00213   bool frozen;
00214   bool ignited; 
00216   std::string dead_script; 
00218 private:
00219   State state;
00220 
00223   bool is_active_flag; 
00224 
00225   Timer state_timer;
00226 
00229   bool on_ground_flag; 
00230 
00233   Vector floor_normal; 
00234   
00236   CollisionGroup colgroup_active;
00237 
00238 private:
00239   BadGuy(const BadGuy&);
00240   BadGuy& operator=(const BadGuy&);
00241 };
00242 
00243 #endif
00244 
00245 /* EOF */

Generated on Mon Jun 9 03:38:16 2014 for SuperTux by  doxygen 1.5.1