invisible_wall.cpp 2.0 KB

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