| 1 | // SuperTux |
| 2 | // Copyright (C) 2006 Matthias Braun <matze@braunis.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 "object/invisible_wall.hpp" |
| 18 | |
| 19 | #include "editor/editor.hpp" |
| 20 | #include "util/reader_mapping.hpp" |
| 21 | #include "video/drawing_context.hpp" |
| 22 | |
| 23 | InvisibleWall::InvisibleWall(const ReaderMapping& mapping): |
| 24 | MovingObject(mapping), |
| 25 | width(), |
| 26 | height() |
| 27 | { |
| 28 | mapping.get("x" , m_col.m_bbox.get_left(), 0.0f); |
| 29 | mapping.get("y" , m_col.m_bbox.get_top(), 0.0f); |
| 30 | mapping.get("width" , width, 32.0f); |
| 31 | mapping.get("height" , height, 32.0f); |
| 32 | |
| 33 | m_col.m_bbox.set_size(width, height); |
| 34 | |
| 35 | m_col.m_group = COLGROUP_STATIC; |
| 36 | } |
| 37 | |
| 38 | ObjectSettings |
| 39 | InvisibleWall::get_settings() |
| 40 | { |
| 41 | width = m_col.m_bbox.get_width(); |
| 42 | height = m_col.m_bbox.get_height(); |
| 43 | |
| 44 | ObjectSettings result = MovingObject::get_settings(); |
| 45 | |
| 46 | //result.add_float(_("Width"), &width, "width"); |
| 47 | //result.add_float(_("Height"), &height, "height"); |
| 48 | |
| 49 | return result; |
| 50 | } |
| 51 | |
| 52 | void |
| 53 | InvisibleWall::after_editor_set() { |
| 54 | m_col.m_bbox.set_size(width, height); |
| 55 | } |
| 56 | |
| 57 | HitResponse |
| 58 | InvisibleWall::collision(GameObject& , const CollisionHit& ) |
| 59 | { |
| 60 | return FORCE_MOVE; |
| 61 | } |
| 62 | |
| 63 | void |
| 64 | InvisibleWall::draw(DrawingContext& context) |
| 65 | { |
| 66 | if (Editor::is_active()) { |
| 67 | context.color().draw_filled_rect(m_col.m_bbox, Color(0.0f, 0.0f, 0.0f, 0.6f), |
| 68 | 0.0f, LAYER_OBJECTS); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | void |
| 73 | InvisibleWall::update(float ) |
| 74 | { |
| 75 | } |
| 76 | |
| 77 | /* EOF */ |
| 78 | |