17 #ifndef HEADER_SUPERTUX_BADGUY_BADGUY_HPP 18 #define HEADER_SUPERTUX_BADGUY_BADGUY_HPP 20 #include "editor/object_option.hpp" 21 #include "object/moving_sprite.hpp" 22 #include "object/portable.hpp" 23 #include "supertux/physic.hpp" 24 #include "supertux/timer.hpp" 42 static void register_class(ssq::VM& vm);
45 BadGuy(
const Vector& pos,
const std::string& sprite_name,
int layer = LAYER_OBJECTS,
46 const std::string& light_sprite_name =
"images/objects/lightmap_light/lightmap_light-medium.sprite",
47 const std::string& ice_sprite_name =
"images/creatures/overlays/iceoverlay/iceoverlay.sprite");
48 BadGuy(
const Vector& pos, Direction direction,
const std::string& sprite_name,
int layer = LAYER_OBJECTS,
49 const std::string& light_sprite_name =
"images/objects/lightmap_light/lightmap_light-medium.sprite",
50 const std::string& ice_sprite_name =
"images/creatures/overlays/iceoverlay/iceoverlay.sprite");
51 BadGuy(
const ReaderMapping& reader,
const std::string& sprite_name,
int layer = LAYER_OBJECTS,
52 const std::string& light_sprite_name =
"images/objects/lightmap_light/lightmap_light-medium.sprite",
53 const std::string& ice_sprite_name =
"images/creatures/overlays/iceoverlay/iceoverlay.sprite");
54 BadGuy(
const ReaderMapping& reader,
const std::string& sprite_name, Direction default_direction,
int layer = LAYER_OBJECTS,
55 const std::string& light_sprite_name =
"images/objects/lightmap_light/lightmap_light-medium.sprite",
56 const std::string& ice_sprite_name =
"images/creatures/overlays/iceoverlay/iceoverlay.sprite");
64 virtual void update(
float dt_sec)
override;
66 static std::string class_name() {
return "badguy"; }
67 virtual std::string get_class_name()
const override {
return class_name(); }
68 virtual std::string get_exposed_class_name()
const override {
return "BadGuy"; }
69 static std::string display_name() {
return _(
"Badguy"); }
73 virtual std::string get_overlay_size()
const {
return "1x1"; }
76 virtual void after_editor_set()
override;
90 #ifdef DOXYGEN_SCRIPTING 105 Vector get_start_position()
const {
return m_start_position; }
106 void set_start_position(
const Vector& vec) { m_start_position = vec; }
108 virtual void grab(
MovingObject&
object,
const Vector& pos, Direction dir)
override;
109 virtual void ungrab(
MovingObject&
object, Direction dir)
override;
110 virtual bool is_portable()
const override;
131 virtual void unfreeze(
bool melt =
true);
133 virtual bool is_freezable()
const;
143 virtual bool always_active()
const {
return false; }
145 bool is_frozen()
const;
147 bool is_in_water()
const;
151 return "images/objects/water_drop/water_drop.sprite";
160 Physic& get_physic() {
return m_physic; }
171 STATE_GROUND_MELTING,
172 STATE_INSIDE_MELTING,
183 virtual void on_flip(
float height)
override;
218 void set_state(State state);
219 State get_state()
const {
return m_state; }
221 bool check_state_timer() {
222 return m_state_timer.
check();
274 Vector m_start_position;
288 float m_melting_time;
290 SpritePtr m_lightsprite;
291 SpritePtr m_freezesprite;
293 bool m_water_affected;
295 Timer m_unfreeze_timer;
302 bool m_is_active_flag;
308 bool m_on_ground_flag;
312 Vector m_floor_normal;
315 CollisionGroup m_colgroup_active;
virtual HitResponse collision_player(Player &player, const CollisionHit &hit)
Called when the badguy collided with a player.
Definition: badguy.cpp:552
Base class for moving sprites that can hurt the Player.
Definition: badguy.hpp:38
virtual HitResponse collision_badguy(BadGuy &other, const CollisionHit &hit)
Called when the badguy collided with another badguy.
Definition: badguy.cpp:589
virtual void deactivate()
called when the badguy has been deactivated
Definition: badguy.cpp:372
virtual void add_wind_velocity(const Vector &velocity, const Vector &end_speed)
Adds velocity from wind.
Definition: badguy.cpp:1191
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user's locale.
Definition: badguy.hpp:70
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: badguy.hpp:71
bool on_ground() const
Returns true if we touched ground in the past frame This only works if update_on_ground_flag() gets c...
Definition: badguy.cpp:873
virtual void ignite()
Kills the badguy by igniting it.
Definition: badguy.cpp:1057
virtual void on_flip(float height) override
When level is flipped vertically.
Definition: badguy.cpp:543
bool m_is_initialized
true if initialize() has already been called
Definition: badguy.hpp:272
virtual HitResponse collision_bullet(Bullet &bullet, const CollisionHit &hit)
Called when the badguy collided with a bullet.
Definition: badguy.cpp:613
virtual void initialize()
called immediately before the first call to initialize
Definition: badguy.cpp:362
virtual void activate()
called when the badguy has been activated.
Definition: badguy.cpp:367
virtual bool can_break() const
True if this badguy can break bricks or open bonusblocks in his current form.
Definition: badguy.hpp:103
Definition: bullet.hpp:29
Physics engine.
Definition: physic.hpp:27
bool is_active() const
Returns true if we were in STATE_ACTIVE at the beginning of the last call to update() ...
Definition: badguy.cpp:879
virtual void extinguish()
Called to revert a badguy when is_ignited() returns true.
Definition: badguy.cpp:1107
virtual void freeze()
Called when hit by an ice bullet, and is_freezable() returns true.
Definition: badguy.cpp:968
std::string m_dead_script
< true if the badguy is currently in water
Definition: badguy.hpp:286
virtual bool is_flammable() const
Returns whether to call ignite() when a badguy gets hit by a fire bullet.
Definition: badguy.cpp:1112
Player * get_nearest_player() const
returns a pointer to the nearest player or 0 if no player is available
Definition: badguy.cpp:858
An object that inherits from this object is considered "portable" and can be carried around by the pl...
Definition: portable.hpp:29
void set_colgroup_active(CollisionGroup group)
changes colgroup_active.
Definition: badguy.cpp:1124
Definition: object_settings.hpp:39
virtual bool is_snipable() const
Can enemy be sniped by sliding or swimboosting Tux? Returns false if enemy is spiky or too large...
Definition: badguy.hpp:141
virtual std::string get_water_sprite() const
Get melting particle sprite filename.
Definition: badguy.hpp:150
bool m_countMe
Count this badguy to the statistics? This value should not be changed during runtime.
Definition: badguy.hpp:268
virtual std::vector< Direction > get_allowed_directions() const
Returns a vector of directions the badguy can be set to.
Definition: badguy.cpp:377
virtual HitResponse collision(GameObject &other, const CollisionHit &hit) override
Called when a collision with another object occurred.
Definition: badguy.cpp:446
virtual void inactive_update(float dt_sec)
called each frame when the badguy is not activated.
Definition: badguy.cpp:407
bool m_ignited
true if this badguy is currently on fire
Definition: badguy.hpp:283
virtual void collision_tile(uint32_t tile_attributes) override
Called when a collision with tile with special attributes occurred.
Definition: badguy.cpp:412
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: moving_sprite.hpp:60
Vector get_floor_normal() const
Returns floor normal stored the last time when update_on_ground_flag was called and we touched someth...
Definition: badguy.cpp:885
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
bool check()
returns true if a period (or more) passed since start call or last successful check ...
Definition: timer.cpp:39
bool is_offscreen() const
initial position of the enemy.
Definition: badguy.cpp:781
virtual bool can_be_affected_by_wind() const
Returns true if the badguy can currently be affected by wind.
Definition: badguy.cpp:1185
Base class for all dynamic/moving game objects.
Definition: moving_object.hpp:35
virtual bool is_hurtable() const
Return true if this badguy can be hurt by tiles with the attribute "hurts".
Definition: badguy.hpp:137
virtual void kill_fall()
Set the badguy to kill/falling state, which makes him falling of the screen (his sprite is turned ups...
Definition: badguy.cpp:678
Direction m_dir
The direction we currently face in.
Definition: badguy.hpp:277
virtual void active_update(float dt_sec)
called each frame when the badguy is activated.
Definition: badguy.cpp:383
virtual void update(float dt_sec) override
Called each frame.
Definition: badguy.cpp:183
virtual void grab(MovingObject &object, const Vector &pos, Direction dir) override
called each frame when the object has been grabbed.
Definition: badguy.cpp:891
Direction m_start_dir
The direction we initially faced in.
Definition: badguy.hpp:280
A helper structure to list all the type_indexes of the classes in the type hierarchy of a given class...
Definition: game_object.hpp:57
virtual void collision_solid(const CollisionHit &hit) override
Called when the badguy collided with solid ground.
Definition: badguy.cpp:516
bool is_ignited() const
Returns whether this badguys is currently on fire.
Definition: badguy.cpp:1118
virtual bool collision_squished(GameObject &object)
Called when the player hit the badguy from above.
Definition: badguy.cpp:597
Simple timer designed to be used in the update functions of objects.
Definition: timer.hpp:24
Definition: reader_mapping.hpp:32
Abstract base class for ""MovingObject""s, that are represented by a sprite.
Definition: moving_sprite.hpp:33
bool might_fall(int height=1) const
Returns true if we might soon fall at least height pixels.
Definition: badguy.cpp:836
This module contains methods controlling the player.
Definition: player.hpp:47
virtual void draw(DrawingContext &context) override
Called when the badguy is drawn.
Definition: badguy.cpp:140
void update_on_ground_flag(const CollisionHit &hit)
Update on_ground_flag judging by solid collision hit.
Definition: badguy.cpp:864
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42
virtual void unfreeze(bool melt=true)
Called to unfreeze the badguy.
Definition: badguy.cpp:1006
virtual void run_dead_script()
Call this, if you use custom kill_fall() or kill_squashed(GameObject& object)
Definition: badguy.cpp:720
This class collects data about a collision.
Definition: collision_hit.hpp:44