00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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", -1, ANCHOR_BOTTOM);
00063 kill_squished(object);
00064 return true;
00065 }
00066
00067