#include <moving_object.hpp>
Inherits GameObject.
Inherited by Block, Bullet, Flower, MovingSprite, Player, TriggerBase, and Wind.
Public Member Functions | |
MovingObject () | |
virtual | ~MovingObject () |
virtual void | collision_solid (const CollisionHit &hit) |
this function is called when the object collided with something solid | |
virtual bool | collides (GameObject &other, const CollisionHit &hit) |
when 2 objects collided, we will first call the pre_collision_check functions of both objects that can decide on how to react to the collision. | |
virtual HitResponse | collision (GameObject &other, const CollisionHit &hit)=0 |
this function is called when the object collided with any other object | |
virtual void | collision_tile (uint32_t tile_attributes) |
called when tiles with special attributes have been touched | |
const Vector & | get_pos () const |
const Rectf & | get_bbox () const |
returns the bounding box of the Object | |
const Vector & | get_movement () const |
virtual void | set_pos (const Vector &pos) |
places the moving object at a specific position. | |
virtual void | set_width (float w) |
sets the moving object's bbox to a specific width. | |
virtual void | set_size (float w, float h) |
sets the moving object's bbox to a specific size. | |
CollisionGroup | get_group () const |
Protected Member Functions | |
void | set_group (CollisionGroup group) |
Protected Attributes | |
Rectf | bbox |
The bounding box of the object (as used for collision detection, this isn't necessarily the bounding box for graphics). | |
Vector | movement |
The movement that will happen till next frame. | |
CollisionGroup | group |
The collision group. | |
Private Attributes | |
Rectf | dest |
this is only here for internal collision detection use (don't touch this from outside collision detection code) | |
Friends | |
class | Sector |
class | CollisionGrid |
class | Platform |
This class contains things for handling the bounding boxes and collision feedback.
Definition at line 76 of file moving_object.hpp.
MovingObject::MovingObject | ( | ) |
Definition at line 19 of file moving_object.cpp.
00019 : 00020 bbox(), 00021 movement(), 00022 group(COLGROUP_MOVING), 00023 dest() 00024 { 00025 }
MovingObject::~MovingObject | ( | ) | [virtual] |
virtual void MovingObject::collision_solid | ( | const CollisionHit & | hit | ) | [inline, virtual] |
this function is called when the object collided with something solid
Reimplemented in AngryStone, BadGuy, Bomb, BouncingSnowball, CaptainSnowball, Dart, Fish, FlyingSnowBall, Jumpy, KamikazeSnowball, Kugelblitz, MoleRock, MrIceBlock, Owl, Plant, SkullyHop, SkyDive, Snail, SpiderMite, SSpiky, Stalactite, Stumpy, Toad, Totem, WalkingBadguy, Yeti, Zeekling, Bullet, GrowUp, IceCrusher, Player, PowerUp, Rock, ScriptedObject, Star, and Trampoline.
Definition at line 83 of file moving_object.hpp.
Referenced by Sector::collision_static_constrains().
virtual bool MovingObject::collides | ( | GameObject & | other, | |
const CollisionHit & | hit | |||
) | [inline, virtual] |
when 2 objects collided, we will first call the pre_collision_check functions of both objects that can decide on how to react to the collision.
Reimplemented in GhostTree, TreeWillOWisp, WillOWisp, InvisibleBlock, and MagicBlock.
Definition at line 91 of file moving_object.hpp.
Referenced by check_collisions(), and Sector::collision_object().
virtual HitResponse MovingObject::collision | ( | GameObject & | other, | |
const CollisionHit & | hit | |||
) | [pure virtual] |
this function is called when the object collided with any other object
Implemented in BadGuy, Dispenser, GhostTree, Haywire, MrBomb, MrIceBlock, BicyclePlatform, Block, BonusBlock, Brick, Bullet, Candle, Coin, Decal, Explosion, Firefly, Flower, GrowUp, HurtingPlatform, IceCrusher, InvisibleBlock, InvisibleWall, Ispy, Lantern, MagicBlock, OneUp, Platform, Player, PneumaticPlatform, PowerUp, PushButton, Rock, ScriptedObject, SkullTile, Star, Trampoline, UnstableTile, WeakBlock, Wind, Door, and TriggerBase.
Referenced by Sector::collision_object().
virtual void MovingObject::collision_tile | ( | uint32_t | tile_attributes | ) | [inline, virtual] |
called when tiles with special attributes have been touched
Reimplemented in BadGuy, Fish, and Player.
Definition at line 102 of file moving_object.hpp.
const Vector& MovingObject::get_pos | ( | ) | const [inline] |
Definition at line 107 of file moving_object.hpp.
References bbox, and Rectf::p1.
Referenced by Sector::activate(), WillOWisp::activate(), TreeWillOWisp::activate(), Flame::activate(), Dispenser::activate(), Dart::activate(), Zeekling::active_update(), Yeti::active_update(), WillOWisp::active_update(), TreeWillOWisp::active_update(), Totem::active_update(), SpiderMite::active_update(), Jumpy::active_update(), Haywire::active_update(), GhostTree::active_update(), FlyingSnowBall::active_update(), Flame::active_update(), Fish::active_update(), Dispenser::active_update(), Dart::active_update(), Crystallo::active_update(), Bomb::active_update(), AngryStone::active_update(), BicyclePlatform::BicyclePlatform(), Bomb::Bomb(), Block::break_me(), Player::check_bounds(), Coin::collect(), PushButton::collision(), GhostTree::collision(), MoleRock::collision_badguy(), Dart::collision_badguy(), MoleRock::collision_player(), Dart::collision_player(), Rock::collision_solid(), Snail::collision_solid(), MrIceBlock::collision_solid(), MoleRock::collision_solid(), Dart::collision_solid(), Stumpy::collision_squished(), Snowman::collision_squished(), Snail::collision_squished(), MrTree::collision_squished(), MrIceBlock::collision_squished(), MrBomb::collision_squished(), Mole::collision_squished(), Dispenser::collision_squished(), Fish::collision_tile(), TriggerBase::draw(), SkullTile::draw(), ScriptedObject::draw(), Player::draw(), MovingSprite::draw(), InvisibleBlock::draw(), Flower::draw(), Candle::draw(), Bullet::draw(), Block::draw(), WillOWisp::draw(), TreeWillOWisp::draw(), Stalactite::draw(), GhostTree::draw(), Fish::draw(), BadGuy::draw(), Explosion::explode(), Explosion::Explosion(), DartTrap::fire(), Firefly::Firefly(), ScriptedObject::get_pos_x(), ScriptedObject::get_pos_y(), Rock::grab(), SkyDive::grab(), MrIceBlock::grab(), MrBomb::grab(), Bomb::grab(), Player::handle_input(), Kugelblitz::hit(), Jumpy::hit(), Owl::initialize(), Totem::jump_on(), KamikazeSnowball::kill_collision(), Mole::kill_fall(), BadGuy::kill_fall(), BadGuy::kill_squished(), Dispenser::launch_badguy(), TitleScreen::make_tux_jump(), PneumaticPlatform::PneumaticPlatform(), EndSequenceWalkRight::running(), EndSequenceWalkLeft::running(), MovingSprite::set_action_centered(), set_pos(), Toad::set_state(), SkullyHop::set_state(), MrIceBlock::set_state(), TitleScreen::setup(), GameSession::setup(), Zeekling::should_we_dive(), WeakBlock::spreadHit(), YetiStalactite::start_shaking(), Totem::synchronize_with(), Mole::throw_rock(), FlipLevelTransformer::transform_moving_object(), FlipLevelTransformer::transform_sector(), Brick::try_break(), BonusBlock::try_open(), Bomb::ungrab(), PneumaticPlatform::update(), Player::update(), Platform::update(), InfoBlock::update(), Coin::update(), Bullet::update(), Block::update(), and BicyclePlatform::update().
const Rectf& MovingObject::get_bbox | ( | ) | const [inline] |
returns the bounding box of the Object
Definition at line 113 of file moving_object.hpp.
References bbox.
Referenced by WillOWisp::active_update(), Stalactite::active_update(), SSpiky::active_update(), Plant::active_update(), GhostTree::active_update(), AngryStone::active_update(), BicyclePlatform::BicyclePlatform(), Igel::can_see(), Player::check_bounds(), InvisibleBlock::collides(), UnstableTile::collision(), PneumaticPlatform::collision(), Brick::collision(), BonusBlock::collision(), Block::collision(), BicyclePlatform::collision(), Dispenser::collision(), BadGuy::collision(), Kugelblitz::collision_player(), Player::collision_solid(), MrTree::collision_squished(), Sector::collision_static_constrains(), Fish::collision_tile(), Sector::collision_tilemap(), Player::draw(), MagicBlock::draw(), Lantern::draw(), InfoBlock::draw(), Yeti::drop_stalactite(), Climbable::event(), Explosion::explode(), ShortFuse::explode(), Bomb::explode(), Explosion::Explosion(), IceCrusher::found_victim(), Player::handle_horizontal_input(), IceCrusher::IceCrusher(), Owl::is_above_player(), BadGuy::is_offscreen(), MrBomb::kill_fall(), Haywire::kill_fall(), Dispenser::launch_badguy(), MagicBlock::MagicBlock(), TitleScreen::make_tux_jump(), Climbable::may_climb(), PneumaticPlatform::PneumaticPlatform(), Player::position_grabbed_object(), Toad::set_state(), GhostTree::spawn_lantern(), Block::start_bounce(), Mole::throw_rock(), FlipLevelTransformer::transform_block(), FlipLevelTransformer::transform_moving_object(), FlipLevelTransformer::transform_platform(), FlipLevelTransformer::transform_sector(), Kugelblitz::try_activate(), BadGuy::try_activate(), Player::try_grab(), BonusBlock::try_open(), Bomb::ungrab(), MagicBlock::update(), Ispy::update(), InfoBlock::update(), IceCrusher::update(), and Camera::update_scroll_normal().
00114 { 00115 return bbox; 00116 }
const Vector& MovingObject::get_movement | ( | ) | const [inline] |
Definition at line 118 of file moving_object.hpp.
References movement.
Referenced by InvisibleBlock::collides(), Kugelblitz::collision_player(), and Sector::collision_static_constrains().
00119 { 00120 return movement; 00121 }
virtual void MovingObject::set_pos | ( | const Vector & | pos | ) | [inline, virtual] |
places the moving object at a specific position.
Be careful when using this function. There are no collision detection checks performed here so bad things could happen.
Definition at line 126 of file moving_object.hpp.
References bbox, dest, get_pos(), Rectf::move(), and Rectf::set_pos().
Referenced by Totem::active_update(), Root::active_update(), Player::adjust_height(), BicyclePlatform::BicyclePlatform(), Player::check_bounds(), Coin::Coin(), PushButton::collision(), Snowman::collision_squished(), Explosion::Explosion(), Dispenser::launch_badguy(), Player::move(), PneumaticPlatform::PneumaticPlatform(), MovingSprite::set_action(), MovingSprite::set_action_centered(), SpecialRiser::SpecialRiser(), Totem::synchronize_with(), FlipLevelTransformer::transform_moving_object(), Bomb::ungrab(), IceCrusher::update(), and YetiStalactite::update().
virtual void MovingObject::set_width | ( | float | w | ) | [inline, virtual] |
sets the moving object's bbox to a specific width.
Be careful when using this function. There are no collision detection checks performed here so bad things could happen.
Definition at line 135 of file moving_object.hpp.
References bbox, dest, and Rectf::set_width().
Referenced by Player::update().
virtual void MovingObject::set_size | ( | float | w, | |
float | h | |||
) | [inline, virtual] |
sets the moving object's bbox to a specific size.
Be careful when using this function. There are no collision detection checks performed here so bad things could happen.
Definition at line 144 of file moving_object.hpp.
References bbox, dest, and Rectf::set_size().
Referenced by Player::adjust_height(), Stumpy::collision_squished(), Player::init(), Player::move(), MovingSprite::set_action(), and MovingSprite::set_action_centered().
CollisionGroup MovingObject::get_group | ( | ) | const [inline] |
Definition at line 150 of file moving_object.hpp.
References group.
Referenced by Player::collision(), BadGuy::collision(), and Player::try_grab().
00151 { 00152 return group; 00153 }
void MovingObject::set_group | ( | CollisionGroup | group | ) | [inline, protected] |
Definition at line 160 of file moving_object.hpp.
Referenced by Block::Block(), Decal::Decal(), Flower::Flower(), BadGuy::freeze(), Rock::grab(), InvisibleBlock::hit(), HurtingPlatform::HurtingPlatform(), Player::kill(), BadGuy::kill_squished(), MagicBlock::MagicBlock(), MovingSprite::MovingSprite(), Rock::Rock(), ScriptedObject::ScriptedObject(), BadGuy::set_colgroup_active(), Player::set_ghost_mode(), ScriptedObject::set_solid(), IceCrusher::set_state(), BadGuy::set_state(), Player::set_visible(), Stalactite::squish(), TriggerBase::TriggerBase(), BadGuy::unfreeze(), Rock::ungrab(), WeakBlock::update(), UnstableTile::update(), MagicBlock::update(), and Wind::Wind().
friend class Sector [friend] |
Definition at line 156 of file moving_object.hpp.
friend class CollisionGrid [friend] |
Definition at line 157 of file moving_object.hpp.
friend class Platform [friend] |
Definition at line 158 of file moving_object.hpp.
Rectf MovingObject::bbox [protected] |
The bounding box of the object (as used for collision detection, this isn't necessarily the bounding box for graphics).
Definition at line 167 of file moving_object.hpp.
Referenced by Stalactite::active_update(), Owl::active_update(), GhostTree::active_update(), FlyingSnowBall::active_update(), Player::adjust_height(), BadGuy::BadGuy(), Block::Block(), BonusBlock::BonusBlock(), Brick::Brick(), Bullet::Bullet(), Climbable::Climbable(), PushButton::collision(), Firefly::collision(), Dispenser::collision(), BadGuy::collision(), Totem::collision_squished(), Stumpy::collision_squished(), PoisonIvy::collision_squished(), Dispenser::Dispenser(), Door::Door(), Switch::draw(), Door::draw(), Candle::draw(), Explosion::explode(), SkyDive::explode(), Firefly::Firefly(), Flame::Flame(), Flower::Flower(), get_bbox(), get_pos(), Player::handle_input(), InfoBlock::InfoBlock(), WalkingBadguy::initialize(), Stumpy::initialize(), InvisibleBlock::InvisibleBlock(), InvisibleWall::InvisibleWall(), Totem::jump_off(), Totem::jump_on(), CaptainSnowball::might_climb(), BadGuy::might_fall(), ScriptedObject::move(), MovingSprite::MovingSprite(), Platform::Platform(), Candle::puff_smoke(), PushButton::PushButton(), ScriptedObject::ScriptedObject(), ScriptTrigger::ScriptTrigger(), SecretAreaTrigger::SecretAreaTrigger(), SequenceTrigger::SequenceTrigger(), MovingSprite::set_action(), MovingSprite::set_action_centered(), Player::set_bonus(), set_pos(), ScriptedObject::set_pos(), set_size(), MrIceBlock::set_state(), set_width(), Block::start_bounce(), Switch::Switch(), Player::try_grab(), Switch::update(), Wind::update(), SkullTile::update(), Player::update(), OneUp::update(), BicyclePlatform::update(), BadGuy::update(), and Wind::Wind().
Vector MovingObject::movement [protected] |
The movement that will happen till next frame.
Definition at line 170 of file moving_object.hpp.
Referenced by Yeti::active_update(), WillOWisp::active_update(), TreeWillOWisp::active_update(), Stalactite::active_update(), SpiderMite::active_update(), SkyDive::active_update(), FlyingSnowBall::active_update(), Flame::active_update(), Bomb::active_update(), BadGuy::active_update(), Fish::collision_tile(), get_movement(), Rock::grab(), SkyDive::grab(), MrIceBlock::grab(), MrBomb::grab(), Bomb::grab(), UnstableTile::update(), Star::update(), SkullTile::update(), ScriptedObject::update(), Rock::update(), PowerUp::update(), PneumaticPlatform::update(), Player::update(), Platform::update(), OneUp::update(), IceCrusher::update(), GrowUp::update(), Coin::update(), Bullet::update(), Block::update(), BicyclePlatform::update(), and BadGuy::update().
CollisionGroup MovingObject::group [protected] |
Rectf MovingObject::dest [private] |
this is only here for internal collision detection use (don't touch this from outside collision detection code)
This field holds the currently anticipated destination of the object during collision detection
Definition at line 181 of file moving_object.hpp.
Referenced by Sector::collision_object(), Sector::collision_static_constrains(), Player::handle_input(), set_pos(), set_size(), set_width(), and BicyclePlatform::update().