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);
30 sound_manager->preload("sounds/fall.wav");
31 sound_manager->preload("sounds/stomp.wav");
34 MoleRock::MoleRock(const Vector& pos, const Vector& velocity, const BadGuy* parent = 0)
35 : BadGuy(pos, LEFT, "images/creatures/mole/mole_rock.sprite", LAYER_TILES - 2), parent(parent), initial_velocity(velocity)
37 physic.enable_gravity(true);
39 sound_manager->preload("sounds/fall.wav");
40 sound_manager->preload("sounds/stomp.wav");
43 MoleRock::MoleRock(const MoleRock& other)
44 : BadGuy(other), parent(other.parent), initial_velocity(Vector(0, -400))
46 sound_manager->preload("sounds/fall.wav");
47 sound_manager->preload("sounds/stomp.wav");
55 MoleRock::updatePointers(const GameObject* from_object, GameObject* to_object)
57 if (from_object == parent) {
58 parent = dynamic_cast<MoleRock*>(to_object);
65 MoleRock::write(lisp::Writer& writer)
67 writer.start_list("mole_rock");
68 writer.write_float("x", start_position.x);
69 writer.write_float("y", start_position.y);
70 writer.end_list("mole_rock");
74 MoleRock::initialize()
76 physic.set_velocity(initial_velocity);
77 sprite->set_action("default");
81 MoleRock::deactivate()
87 MoleRock::active_update(float elapsed_time)
89 BadGuy::active_update(elapsed_time);
93 MoleRock::collision_solid(const CollisionHit& )
95 sound_manager->play("sounds/darthit.wav", get_pos());
100 MoleRock::collision_badguy(BadGuy& badguy, const CollisionHit& )
102 // ignore collisions with parent
103 if (&badguy == parent) {
106 sound_manager->play("sounds/stomp.wav", get_pos());
113 MoleRock::collision_player(Player& player, const CollisionHit& hit)
115 sound_manager->play("sounds/stomp.wav", get_pos());
117 return BadGuy::collision_player(player, hit);
120 IMPLEMENT_FACTORY(MoleRock, "mole_rock")