#include <moving_sprite.hpp>
Inherits MovingObject.
Inherited by BadGuy, BicyclePlatform, Candle, Coin, Decal, Explosion, Firefly, GrowUp, IceCrusher, InvisibleWall, Ispy, MagicBlock, OneUp, Platform, PneumaticPlatform, PowerUp, PushButton, Rock, ScriptedObject, SkullTile, Star, UnstableTile, and WeakBlock.
Public Member Functions | |
MovingSprite (const Vector &pos, const std::string &sprite_name, int layer=LAYER_OBJECTS, CollisionGroup collision_group=COLGROUP_MOVING) | |
MovingSprite (const Reader &reader, const Vector &pos, int layer=LAYER_OBJECTS, CollisionGroup collision_group=COLGROUP_MOVING) | |
MovingSprite (const Reader &reader, const std::string &sprite_name, int layer=LAYER_OBJECTS, CollisionGroup collision_group=COLGROUP_MOVING) | |
MovingSprite (const Reader &reader, int layer=LAYER_OBJECTS, CollisionGroup collision_group=COLGROUP_MOVING) | |
MovingSprite (const MovingSprite &moving_sprite) | |
~MovingSprite () | |
virtual void | draw (DrawingContext &context) |
The GameObject should draw itself onto the provided DrawingContext if this function is called. | |
virtual void | update (float elapsed_time) |
This function is called once per frame and allows the object to update it's state. | |
Protected Member Functions | |
void | set_action (const std::string &action, int loops) |
set new action for sprite and resize bounding box. | |
void | set_action_centered (const std::string &action, int loops) |
set new action for sprite and re-center bounding box. | |
void | set_action (const std::string &action, int loops, AnchorPoint anchorPoint) |
set new action for sprite and align bounding boxes at anchorPoint. | |
Protected Attributes | |
std::string | sprite_name |
SpritePtr | sprite |
int | layer |
Sprite's z-position. | |
Private Member Functions | |
MovingSprite & | operator= (const MovingSprite &) |
Definition at line 29 of file moving_sprite.hpp.
MovingSprite::MovingSprite | ( | const Vector & | pos, | |
const std::string & | sprite_name, | |||
int | layer = LAYER_OBJECTS , |
|||
CollisionGroup | collision_group = COLGROUP_MOVING | |||
) |
Definition at line 24 of file moving_sprite.cpp.
References MovingObject::bbox, SpriteManager::create(), MovingObject::set_group(), Rectf::set_pos(), Rectf::set_size(), sprite, and sprite_manager.
00025 : 00026 sprite_name(sprite_name), 00027 sprite(), 00028 layer(layer) 00029 { 00030 bbox.set_pos(pos); 00031 sprite = sprite_manager->create(sprite_name); 00032 bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height()); 00033 set_group(collision_group); 00034 }
MovingSprite::MovingSprite | ( | const Reader & | reader, | |
const Vector & | pos, | |||
int | layer = LAYER_OBJECTS , |
|||
CollisionGroup | collision_group = COLGROUP_MOVING | |||
) |
Definition at line 36 of file moving_sprite.cpp.
References MovingObject::bbox, SpriteManager::create(), lisp::Lisp::get(), MovingObject::set_group(), Rectf::set_pos(), Rectf::set_size(), sprite, sprite_manager, and sprite_name.
00036 : 00037 sprite_name(), 00038 sprite(), 00039 layer(layer) 00040 { 00041 bbox.set_pos(pos); 00042 if (!reader.get("sprite", sprite_name)) 00043 throw std::runtime_error("no sprite name set"); 00044 00045 sprite = sprite_manager->create(sprite_name); 00046 bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height()); 00047 set_group(collision_group); 00048 }
MovingSprite::MovingSprite | ( | const Reader & | reader, | |
const std::string & | sprite_name, | |||
int | layer = LAYER_OBJECTS , |
|||
CollisionGroup | collision_group = COLGROUP_MOVING | |||
) |
Definition at line 50 of file moving_sprite.cpp.
References MovingObject::bbox, SpriteManager::create(), lisp::Lisp::get(), Rectf::p1, MovingObject::set_group(), Rectf::set_size(), sprite, sprite_manager, Vector::x, and Vector::y.
00050 : 00051 sprite_name(sprite_name), 00052 sprite(), 00053 layer(layer) 00054 { 00055 reader.get("x", bbox.p1.x); 00056 reader.get("y", bbox.p1.y); 00057 reader.get("sprite", this->sprite_name); 00058 00059 sprite = sprite_manager->create(this->sprite_name); 00060 bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height()); 00061 set_group(collision_group); 00062 }
MovingSprite::MovingSprite | ( | const Reader & | reader, | |
int | layer = LAYER_OBJECTS , |
|||
CollisionGroup | collision_group = COLGROUP_MOVING | |||
) |
Definition at line 64 of file moving_sprite.cpp.
References MovingObject::bbox, SpriteManager::create(), lisp::Lisp::get(), Rectf::p1, MovingObject::set_group(), Rectf::set_size(), sprite, sprite_manager, sprite_name, Vector::x, and Vector::y.
00064 : 00065 sprite_name(), 00066 sprite(), 00067 layer(layer) 00068 { 00069 reader.get("x", bbox.p1.x); 00070 reader.get("y", bbox.p1.y); 00071 if (!reader.get("sprite", sprite_name)) 00072 throw std::runtime_error("no sprite name set"); 00073 00074 sprite = sprite_manager->create(sprite_name); 00075 bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height()); 00076 set_group(collision_group); 00077 }
MovingSprite::MovingSprite | ( | const MovingSprite & | moving_sprite | ) |
Definition at line 79 of file moving_sprite.cpp.
References sprite.
00079 : 00080 MovingObject(other), 00081 sprite_name(), 00082 sprite(), 00083 layer(other.layer) 00084 { 00085 sprite = other.sprite->clone(); 00086 } /*
MovingSprite::~MovingSprite | ( | ) |
void MovingSprite::draw | ( | DrawingContext & | context | ) | [virtual] |
The GameObject should draw itself onto the provided DrawingContext if this function is called.
Implements GameObject.
Reimplemented in BadGuy, Fish, GhostTree, Root, Stalactite, TreeWillOWisp, WillOWisp, Yeti, Candle, Lantern, MagicBlock, ScriptedObject, and SkullTile.
Definition at line 107 of file moving_sprite.cpp.
References MovingObject::get_pos(), layer, and sprite.
Referenced by MagicBlock::draw(), and Lantern::draw().
void MovingSprite::update | ( | float | elapsed_time | ) | [virtual] |
This function is called once per frame and allows the object to update it's state.
The elapsed_time is the time since the last frame in seconds and should be the base for all timed calculations (don't use SDL_GetTicks directly as this will fail in pause mode)
Implements GameObject.
Reimplemented in BadGuy, YetiStalactite, BicyclePlatform, Coin, Explosion, GrowUp, IceCrusher, Ispy, MagicBlock, OneUp, Platform, PneumaticPlatform, PowerUp, PushButton, Rock, ScriptedObject, SkullTile, Star, Trampoline, UnstableTile, and WeakBlock.
Definition at line 113 of file moving_sprite.cpp.
void MovingSprite::set_action | ( | const std::string & | action, | |
int | loops | |||
) | [protected] |
set new action for sprite and resize bounding box.
use with care as you can easily get stuck when resizing the bounding box.
Definition at line 118 of file moving_sprite.cpp.
References MovingObject::set_size(), and sprite.
Referenced by WalkingBadguy::active_update(), Bomb::Bomb(), PushButton::collision(), Owl::collision_solid(), MrIceBlock::collision_solid(), Snowman::collision_squished(), Haywire::collision_squished(), Crystallo::collision_squished(), Decal::Decal(), UnstableTile::dissolve(), Explosion::explode(), UnstableTile::fall_down(), MrIceBlock::grab(), KamikazeSnowball::KamikazeSnowball(), Owl::Owl(), PushButton::PushButton(), MrIceBlock::set_state(), UnstableTile::shake(), and UnstableTile::slow_fall().
00119 { 00120 sprite->set_action(action, loops); 00121 set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height()); 00122 }
void MovingSprite::set_action_centered | ( | const std::string & | action, | |
int | loops | |||
) | [protected] |
set new action for sprite and re-center bounding box.
use with care as you can easily get stuck when resizing the bounding box.
Definition at line 125 of file moving_sprite.cpp.
References MovingObject::bbox, MovingObject::get_pos(), Rectf::get_size(), MovingObject::set_pos(), MovingObject::set_size(), and sprite.
00126 { 00127 Vector old_size = bbox.get_size(); 00128 sprite->set_action(action, loops); 00129 set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height()); 00130 set_pos(get_pos() - (bbox.get_size() - old_size) / 2); 00131 }
void MovingSprite::set_action | ( | const std::string & | action, | |
int | loops, | |||
AnchorPoint | anchorPoint | |||
) | [protected] |
set new action for sprite and align bounding boxes at anchorPoint.
use with care as you can easily get stuck when resizing the bounding box.
Definition at line 134 of file moving_sprite.cpp.
References MovingObject::bbox, get_anchor_pos(), MovingObject::set_pos(), MovingObject::set_size(), and sprite.
00135 { 00136 Rectf old_bbox = bbox; 00137 sprite->set_action(action, loops); 00138 float w = sprite->get_current_hitbox_width(); 00139 float h = sprite->get_current_hitbox_height(); 00140 set_size(w, h); 00141 set_pos(get_anchor_pos(old_bbox, w, h, anchorPoint)); 00142 }
MovingSprite& MovingSprite::operator= | ( | const MovingSprite & | ) | [private] |
std::string MovingSprite::sprite_name [protected] |
Definition at line 55 of file moving_sprite.hpp.
Referenced by PowerUp::collision(), MrBomb::collision_squished(), Firefly::Firefly(), Haywire::Haywire(), MovingSprite(), MrBomb::MrBomb(), ShortFuse::ShortFuse(), and Trampoline::Trampoline().
SpritePtr MovingSprite::sprite [protected] |
Definition at line 56 of file moving_sprite.hpp.
Referenced by Dispenser::activate(), Zeekling::active_update(), Yeti::active_update(), WillOWisp::active_update(), TreeWillOWisp::active_update(), SSpiky::active_update(), SpiderMite::active_update(), Snail::active_update(), SkullyHop::active_update(), Root::active_update(), Plant::active_update(), Mole::active_update(), Jumpy::active_update(), GhostTree::active_update(), FlyingSnowBall::active_update(), Fish::active_update(), Dispenser::active_update(), DartTrap::active_update(), Bomb::active_update(), AngryStone::active_update(), AngryStone::AngryStone(), Yeti::be_angry(), Snail::be_flat(), Snail::be_kicked(), Candle::Candle(), Trampoline::collision(), Firefly::collision(), Plant::collision_badguy(), WillOWisp::collision_player(), Yeti::collision_solid(), Snail::collision_solid(), SkullyHop::collision_solid(), Plant::collision_solid(), BouncingSnowball::collision_solid(), AngryStone::collision_solid(), Zeekling::collision_squished(), WalkingLeaf::collision_squished(), Totem::collision_squished(), Toad::collision_squished(), Stumpy::collision_squished(), SpiderMite::collision_squished(), SnowBall::collision_squished(), SmartBall::collision_squished(), SkullyHop::collision_squished(), PoisonIvy::collision_squished(), MrTree::collision_squished(), KamikazeSnowball::collision_squished(), FlyingSnowBall::collision_squished(), Dispenser::collision_squished(), CaptainSnowball::collision_squished(), BouncingSnowball::collision_squished(), GhostTree::die(), Dispenser::Dispenser(), UnstableTile::dissolve(), SkullTile::draw(), ScriptedObject::draw(), draw(), Candle::draw(), WillOWisp::draw(), TreeWillOWisp::draw(), Stalactite::draw(), Fish::draw(), BadGuy::draw(), Explosion::explode(), Kugelblitz::explode(), UnstableTile::fall_down(), DartTrap::fire(), Firefly::Firefly(), SSpiky::freeze(), Spiky::freeze(), MrBomb::freeze(), Jumpy::freeze(), Haywire::freeze(), Fish::freeze(), ScriptedObject::get_action(), Trampoline::grab(), Lantern::grab(), MrBomb::grab(), Bomb::grab(), Haywire::Haywire(), Kugelblitz::hit(), IceCrusher::IceCrusher(), Zeekling::initialize(), WalkingBadguy::initialize(), Totem::initialize(), Toad::initialize(), Stumpy::initialize(), SSpiky::initialize(), SpiderMite::initialize(), SkullyHop::initialize(), Plant::initialize(), Owl::initialize(), MoleRock::initialize(), KamikazeSnowball::initialize(), FlyingSnowBall::initialize(), DartTrap::initialize(), Dart::initialize(), BouncingSnowball::initialize(), Ispy::Ispy(), Yeti::jump_down(), Totem::jump_off(), Totem::jump_on(), Yeti::jump_up(), KamikazeSnowball::kill_collision(), Kugelblitz::Kugelblitz(), DartTrap::load(), MovingSprite(), MrBomb::MrBomb(), Zeekling::onBumpHorizontal(), Zeekling::onBumpVertical(), PushButton::PushButton(), Firefly::reactivate(), Yeti::run(), ScriptedObject::ScriptedObject(), ScriptedObject::set_action(), set_action(), set_action_centered(), Candle::set_burning(), TreeWillOWisp::set_color(), IceCrusher::set_state(), Toad::set_state(), SkullyHop::set_state(), Mole::set_state(), UnstableTile::shake(), ShortFuse::ShortFuse(), UnstableTile::slow_fall(), Stalactite::squish(), WeakBlock::startBurning(), Totem::synchronize_with(), Yeti::take_hit(), Trampoline::Trampoline(), WalkingBadguy::turn_around(), Lantern::ungrab(), UnstableTile::UnstableTile(), WeakBlock::update(), UnstableTile::update(), Trampoline::update(), MagicBlock::update(), Ispy::update(), Explosion::update(), YetiStalactite::update(), Lantern::updateColor(), WillOWisp::vanish(), TreeWillOWisp::vanish(), WeakBlock::WeakBlock(), and WillOWisp::WillOWisp().
int MovingSprite::layer [protected] |
Sprite's z-position.
Refer to video/drawing_context.hpp for sensible values.
Definition at line 57 of file moving_sprite.hpp.
Referenced by TreeWillOWisp::active_update(), Decal::Decal(), SkullTile::draw(), ScriptedObject::draw(), draw(), MagicBlock::draw(), Candle::draw(), WillOWisp::draw(), TreeWillOWisp::draw(), Stalactite::draw(), GhostTree::draw(), Fish::draw(), BadGuy::draw(), and ScriptedObject::ScriptedObject().