src/badguy/crystallo.cpp

Go to the documentation of this file.
00001 //  SuperTux - Crystallo
00002 //  Copyright (C) 2008 Wolfgang Becker <uafr@gmx.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/crystallo.hpp"
00018 
00019 #include "sprite/sprite.hpp"
00020 #include "supertux/object_factory.hpp"
00021 #include "util/reader.hpp"
00022 #include "object/anchor_point.hpp"
00023 
00024 Crystallo::Crystallo(const Reader& reader) :
00025   WalkingBadguy(reader, "images/creatures/crystallo/crystallo.sprite", "left", "right"),
00026   radius()
00027 {
00028   walk_speed = 80;
00029   max_drop_height = 16;
00030   radius = 100;
00031   reader.get("radius", radius);
00032 }
00033 
00034 Crystallo::Crystallo(const Vector& pos, Direction d) :
00035   WalkingBadguy(pos, d, "images/creatures/crystallo/crystallo.sprite", "left", "right"),
00036   radius()
00037 {
00038   walk_speed = 80;
00039   max_drop_height = 16;
00040   radius = 100;
00041 }
00042 
00043 void
00044 Crystallo::active_update(float elapsed_time)
00045 {
00046   if(get_pos().x > (start_position.x + radius)){
00047     if(dir != LEFT){
00048       turn_around();
00049     }
00050   }
00051   if( get_pos().x < (start_position.x - radius)){
00052     if(dir != RIGHT){
00053       turn_around();
00054     }
00055   }
00056   BadGuy::active_update(elapsed_time);
00057 }
00058 
00059 bool
00060 Crystallo::collision_squished(GameObject& object)
00061 {
00062   this->set_action(dir == LEFT ? "shattered-left" : "shattered-right", /* loops = */ -1, ANCHOR_BOTTOM);
00063   kill_squished(object);
00064   return true;
00065 }
00066 
00067 /* EOF */

Generated on Mon Jun 9 03:38:17 2014 for SuperTux by  doxygen 1.5.1