17 #ifndef HEADER_SUPERTUX_OBJECT_STICKY_OBJECT_HPP 18 #define HEADER_SUPERTUX_OBJECT_STICKY_OBJECT_HPP 20 #include "badguy/badguy.hpp" 21 #include "object/moving_sprite.hpp" 23 #include "supertux/sector.hpp" 30 StickyObject(
const Vector& pos,
const std::string& sprite_name,
31 int layer = LAYER_OBJECTS, CollisionGroup collision_group = COLGROUP_MOVING);
33 int layer = LAYER_OBJECTS, CollisionGroup collision_group = COLGROUP_MOVING);
36 virtual void update(
float dt_sec)
override;
42 bool is_sticky()
const {
return m_sticky; }
48 for (
auto& obj :
Sector::get().get_objects_by_type<T>())
50 if (m_col.
m_bbox.grown(8.f).overlaps(obj.get_bbox()))
52 m_col.set_movement(obj.get_movement());
55 m_displacement_from_owner = get_pos() - obj.get_pos();
67 Vector m_displacement_from_owner;
81 int layer = LAYER_OBJECTS, CollisionGroup collision_group = COLGROUP_MOVING);
83 int layer = LAYER_OBJECTS, CollisionGroup collision_group = COLGROUP_MOVING);
86 virtual void sticky_update(
float dt_sec);
92 bool is_sticky()
const {
return m_sticky; }
98 for (
auto& obj :
Sector::get().get_objects_by_type<T>())
100 if (m_col.m_bbox.grown(8.f).overlaps(obj.get_bbox()))
102 m_col.set_movement(obj.get_movement());
105 m_displacement_from_owner = get_pos() - obj.get_pos();
117 Vector m_displacement_from_owner;
Base class for moving sprites that can hurt the Player.
Definition: badguy.hpp:38
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: badguy.hpp:71
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: sticky_object.hpp:84
Definition: object_settings.hpp:39
Rectf m_bbox
The bounding box of the object (as used for collision detection, this isn't necessarily the bounding ...
Definition: collision_object.hpp:150
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: moving_sprite.hpp:60
virtual void update(float dt_sec) override
This function is called once per frame and allows the object to update it's state.
Definition: sticky_object.cpp:44
Base class for all dynamic/moving game objects.
Definition: moving_object.hpp:35
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: sticky_object.hpp:34
This is a class for BadGuys that can stick to the sides, top and bottom of MovingObjects, such as platforms, fallblock, tilemap, etc.
Definition: sticky_object.hpp:77
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
Definition: reader_mapping.hpp:32
This is a class for MovingSprites that can stick to the sides, top and bottom of MovingObjects, such as platforms, fallblock, tilemap, etc.
Definition: sticky_object.hpp:27
Abstract base class for ""MovingObject""s, that are represented by a sprite.
Definition: moving_sprite.hpp:33
static Sector & get()
get currently activated sector.
Definition: sector.hpp:74