1 // MoleRock - Rock thrown by "Mole" Badguy
2 // Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "badguy/mole_rock.hpp"
19 #include "audio/sound_manager.hpp"
20 #include "sprite/sprite.hpp"
21 #include "supertux/object_factory.hpp"
23 MoleRock::MoleRock(const Reader& reader)
24 : BadGuy(reader, "images/creatures/mole/mole_rock.sprite", LAYER_TILES - 2), parent(0), initial_velocity(Vector(0, -400))
26 physic.enable_gravity(true);
28 sound_manager->preload("sounds/darthit.wav");
29 sound_manager->preload("sounds/stomp.wav");
32 MoleRock::MoleRock(const Vector& pos, const Vector& velocity, const BadGuy* parent = 0) :
33 BadGuy(pos, LEFT, "images/creatures/mole/mole_rock.sprite", LAYER_TILES - 2),
35 initial_velocity(velocity)
37 physic.enable_gravity(true);
39 sound_manager->preload("sounds/darthit.wav");
40 sound_manager->preload("sounds/stomp.wav");
48 MoleRock::updatePointers(const GameObject* from_object, GameObject* to_object)
50 if (from_object == parent) {
51 parent = dynamic_cast<MoleRock*>(to_object);
58 MoleRock::initialize()
60 physic.set_velocity(initial_velocity);
61 sprite->set_action("default");
65 MoleRock::deactivate()
71 MoleRock::active_update(float elapsed_time)
73 BadGuy::active_update(elapsed_time);
77 MoleRock::collision_solid(const CollisionHit& )
79 sound_manager->play("sounds/darthit.wav", get_pos());
84 MoleRock::collision_badguy(BadGuy& badguy, const CollisionHit& )
86 // ignore collisions with parent
87 if (&badguy == parent) {
90 sound_manager->play("sounds/stomp.wav", get_pos());
97 MoleRock::collision_player(Player& player, const CollisionHit& hit)
99 sound_manager->play("sounds/stomp.wav", get_pos());
101 return BadGuy::collision_player(player, hit);
104 IMPLEMENT_FACTORY(MoleRock, "mole_rock");