3 // MoleRock - Rock thrown by "Mole" Badguy
4 // Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23 #include "mole_rock.hpp"
25 MoleRock::MoleRock(const lisp::Lisp& reader)
26 : BadGuy(reader, "images/creatures/mole/mole_rock.sprite", LAYER_TILES - 2), parent(0), initial_velocity(Vector(0, -400))
28 physic.enable_gravity(true);
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), parent(parent), initial_velocity(velocity)
35 physic.enable_gravity(true);
39 MoleRock::MoleRock(const MoleRock& other)
40 : BadGuy(other), parent(other.parent), initial_velocity(Vector(0, -400))
49 MoleRock::updatePointers(const GameObject* from_object, GameObject* to_object)
51 if (from_object == parent) {
52 parent = dynamic_cast<MoleRock*>(to_object);
59 MoleRock::write(lisp::Writer& writer)
61 writer.start_list("mole_rock");
62 writer.write_float("x", start_position.x);
63 writer.write_float("y", start_position.y);
64 writer.end_list("mole_rock");
70 physic.set_velocity(initial_velocity);
71 sprite->set_action("default");
75 MoleRock::deactivate()
81 MoleRock::active_update(float elapsed_time)
83 BadGuy::active_update(elapsed_time);
87 MoleRock::collision_solid(const CollisionHit& )
89 sound_manager->play("sounds/darthit.wav", get_pos());
94 MoleRock::collision_badguy(BadGuy& badguy, const CollisionHit& )
96 // ignore collisions with parent
97 if (&badguy == parent) {
100 sound_manager->play("sounds/stomp.wav", get_pos());
107 MoleRock::collision_player(Player& player, const CollisionHit& hit)
109 sound_manager->play("sounds/stomp.wav", get_pos());
111 return BadGuy::collision_player(player, hit);
114 IMPLEMENT_FACTORY(MoleRock, "mole_rock")