1// SuperTux - Crystallo
2// Copyright (C) 2008 Wolfgang Becker <uafr@gmx.de>
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17#include "badguy/crystallo.hpp"
18
19#include "util/reader_mapping.hpp"
20
21Crystallo::Crystallo(const ReaderMapping& reader) :
22 WalkingBadguy(reader, "images/creatures/crystallo/crystallo.sprite", "left", "right"),
23 m_radius()
24{
25 walk_speed = 80;
26 max_drop_height = 16;
27
28 reader.get("radius", m_radius, 100.0f);
29}
30
31ObjectSettings
32Crystallo::get_settings()
33{
34 ObjectSettings result = WalkingBadguy::get_settings();
35
36 result.add_float(_("Radius"), &m_radius, "radius", 100.0f);
37
38 result.reorder({"radius", "direction", "x", "y"});
39
40 return result;
41}
42
43void
44Crystallo::active_update(float dt_sec)
45{
46 if (get_pos().x > (m_start_position.x + m_radius)) {
47 if (m_dir != Direction::LEFT){
48 turn_around();
49 }
50 }
51
52 if (get_pos().x < (m_start_position.x - m_radius)) {
53 if (m_dir != Direction::RIGHT){
54 turn_around();
55 }
56 }
57
58 BadGuy::active_update(dt_sec);
59}
60
61bool
62Crystallo::collision_squished(GameObject& object)
63{
64 set_action(m_dir == Direction::LEFT ? "shattered-left" : "shattered-right", /* loops = */ -1, ANCHOR_BOTTOM);
65 kill_squished(object);
66 return true;
67}
68
69bool
70Crystallo::is_flammable() const
71{
72 return false;
73}
74
75/* EOF */
76