00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "badguy/mole_rock.hpp"
00018
00019 #include "audio/sound_manager.hpp"
00020 #include "sprite/sprite.hpp"
00021 #include "supertux/object_factory.hpp"
00022
00023 MoleRock::MoleRock(const Reader& reader)
00024 : BadGuy(reader, "images/creatures/mole/mole_rock.sprite", LAYER_TILES - 2), parent(0), initial_velocity(Vector(0, -400))
00025 {
00026 physic.enable_gravity(true);
00027 countMe = false;
00028 sound_manager->preload("sounds/darthit.wav");
00029 sound_manager->preload("sounds/stomp.wav");
00030 }
00031
00032 MoleRock::MoleRock(const Vector& pos, const Vector& velocity, const BadGuy* parent = 0) :
00033 BadGuy(pos, LEFT, "images/creatures/mole/mole_rock.sprite", LAYER_TILES - 2),
00034 parent(parent),
00035 initial_velocity(velocity)
00036 {
00037 physic.enable_gravity(true);
00038 countMe = false;
00039 sound_manager->preload("sounds/darthit.wav");
00040 sound_manager->preload("sounds/stomp.wav");
00041 }
00042
00043 MoleRock::~MoleRock()
00044 {
00045 }
00046
00047 bool
00048 MoleRock::updatePointers(const GameObject* from_object, GameObject* to_object)
00049 {
00050 if (from_object == parent) {
00051 parent = dynamic_cast<MoleRock*>(to_object);
00052 return true;
00053 }
00054 return false;
00055 }
00056
00057 void
00058 MoleRock::initialize()
00059 {
00060 physic.set_velocity(initial_velocity);
00061 sprite->set_action("default");
00062 }
00063
00064 void
00065 MoleRock::deactivate()
00066 {
00067 remove_me();
00068 }
00069
00070 void
00071 MoleRock::active_update(float elapsed_time)
00072 {
00073 BadGuy::active_update(elapsed_time);
00074 }
00075
00076 void
00077 MoleRock::collision_solid(const CollisionHit& )
00078 {
00079 sound_manager->play("sounds/darthit.wav", get_pos());
00080 remove_me();
00081 }
00082
00083 HitResponse
00084 MoleRock::collision_badguy(BadGuy& badguy, const CollisionHit& )
00085 {
00086
00087 if (&badguy == parent) {
00088 return FORCE_MOVE;
00089 }
00090 sound_manager->play("sounds/stomp.wav", get_pos());
00091 remove_me();
00092 badguy.kill_fall();
00093 return ABORT_MOVE;
00094 }
00095
00096 HitResponse
00097 MoleRock::collision_player(Player& player, const CollisionHit& hit)
00098 {
00099 sound_manager->play("sounds/stomp.wav", get_pos());
00100 remove_me();
00101 return BadGuy::collision_player(player, hit);
00102 }
00103
00104