src/badguy/mole_rock.cpp

Go to the documentation of this file.
00001 //  MoleRock - Rock thrown by "Mole" Badguy
00002 //  Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
00003 //
00004 //  This program is free software: you can redistribute it and/or modify
00005 //  it under the terms of the GNU General Public License as published by
00006 //  the Free Software Foundation, either version 3 of the License, or
00007 //  (at your option) any later version.
00008 //
00009 //  This program is distributed in the hope that it will be useful,
00010 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 //  GNU General Public License for more details.
00013 //
00014 //  You should have received a copy of the GNU General Public License
00015 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
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   // ignore collisions with parent
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 /* EOF */

Generated on Mon Apr 14 03:38:19 2014 for SuperTux by  doxygen 1.5.1