#include <short_fuse.hpp>
Inherits WalkingBadguy.
Public Member Functions | |
ShortFuse (const Reader &reader) | |
ShortFuse (const Vector &pos, Direction d) | |
Protected Member Functions | |
HitResponse | collision_player (Player &player, const CollisionHit &hit) |
Called when the badguy collided with a player. | |
bool | collision_squished (GameObject &object) |
Called when the player hit the badguy from above. | |
void | kill_fall (void) |
Set the badguy to kill/falling state, which makes him falling of the screen (his sprite is turned upside-down). | |
void | explode (void) |
Definition at line 23 of file short_fuse.hpp.
ShortFuse::ShortFuse | ( | const Reader & | reader | ) |
Definition at line 32 of file short_fuse.cpp.
References SpriteManager::create(), lisp::Lisp::get(), WalkingBadguy::max_drop_height, SoundManager::preload(), sound_manager, MovingSprite::sprite, sprite_manager, MovingSprite::sprite_name, and WalkingBadguy::walk_speed.
00032 : 00033 WalkingBadguy(reader, "images/creatures/short_fuse/short_fuse.sprite", "left", "right") 00034 { 00035 walk_speed = 100; 00036 max_drop_height = -1; 00037 00038 //Prevent stutter when Tux jumps on Mr Bomb 00039 sound_manager->preload("sounds/explosion.wav"); 00040 00041 //Check if we need another sprite 00042 if( !reader.get( "sprite", sprite_name ) ){ 00043 return; 00044 } 00045 if( sprite_name == "" ){ 00046 sprite_name = "images/creatures/short_fuse/short_fuse.sprite"; 00047 return; 00048 } 00049 //Replace sprite 00050 sprite = sprite_manager->create( sprite_name ); 00051 }
Definition at line 54 of file short_fuse.cpp.
References WalkingBadguy::max_drop_height, SoundManager::preload(), sound_manager, and WalkingBadguy::walk_speed.
00054 : 00055 WalkingBadguy(pos, d, "images/creatures/short_fuse/short_fuse.sprite", "left", "right") 00056 { 00057 walk_speed = 80; 00058 max_drop_height = 16; 00059 sound_manager->preload("sounds/explosion.wav"); 00060 }
HitResponse ShortFuse::collision_player | ( | Player & | player, | |
const CollisionHit & | hit | |||
) | [protected, virtual] |
Called when the badguy collided with a player.
Reimplemented from BadGuy.
Definition at line 93 of file short_fuse.cpp.
References ABORT_MOVE, Player::bounce(), and explode().
00094 { 00095 player.bounce (*this); 00096 explode (); 00097 return ABORT_MOVE; 00098 }
bool ShortFuse::collision_squished | ( | GameObject & | object | ) | [protected, virtual] |
Called when the player hit the badguy from above.
You should return true if the badguy was squished, false if squishing wasn't possible
Reimplemented from BadGuy.
Definition at line 78 of file short_fuse.cpp.
References Player::bounce(), explode(), and GameObject::is_valid().
00079 { 00080 if (!is_valid ()) 00081 return true; 00082 00083 Player* player = dynamic_cast<Player*>(&obj); 00084 if(player) 00085 player->bounce(*this); 00086 00087 explode (); 00088 00089 return true; 00090 }
void ShortFuse::kill_fall | ( | void | ) | [protected, virtual] |
Set the badguy to kill/falling state, which makes him falling of the screen (his sprite is turned upside-down).
Reimplemented from BadGuy.
Definition at line 101 of file short_fuse.cpp.
References explode(), and BadGuy::run_dead_script().
00102 { 00103 explode (); 00104 run_dead_script (); 00105 }
void ShortFuse::explode | ( | void | ) | [protected] |
Definition at line 63 of file short_fuse.cpp.
References Sector::add_object(), Sector::current(), MovingObject::get_bbox(), Explosion::hurts(), GameObject::is_valid(), Explosion::pushes(), and GameObject::remove_me().
Referenced by collision_player(), collision_squished(), and kill_fall().
00064 { 00065 if (!is_valid ()) 00066 return; 00067 00068 Explosion *explosion = new Explosion (get_bbox ().get_middle ()); 00069 00070 explosion->hurts (false); 00071 explosion->pushes (true); 00072 Sector::current()->add_object (explosion); 00073 00074 remove_me (); 00075 }