spawnpoint.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // SuperTux
  2. // Copyright (C) 2015 Hume2 <teratux.mail@gmail.com>
  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/spawnpoint.hpp"
  17. #include "editor/editor.hpp"
  18. #include "supertux/debug.hpp"
  19. #include "util/reader_mapping.hpp"
  20. #include "video/drawing_context.hpp"
  21. #include "video/surface.hpp"
  22. SpawnPointMarker::SpawnPointMarker(const std::string& name, const Vector& pos) :
  23. m_surface(Surface::from_file("images/engine/editor/spawnpoint.png"))
  24. {
  25. m_name = name;
  26. m_col.m_bbox.set_p1(pos);
  27. m_col.m_bbox.set_size(32, 32);
  28. if (!Editor::is_active()) {
  29. set_group(COLGROUP_DISABLED);
  30. }
  31. }
  32. SpawnPointMarker::SpawnPointMarker(const ReaderMapping& mapping) :
  33. m_surface(Surface::from_file("images/engine/editor/spawnpoint.png"))
  34. {
  35. mapping.get("name", m_name, "");
  36. mapping.get("x", m_col.m_bbox.get_left(), 0.0f);
  37. mapping.get("y", m_col.m_bbox.get_top(), 0.0f);
  38. m_col.m_bbox.set_size(32, 32);
  39. set_group(COLGROUP_DISABLED);
  40. }
  41. void
  42. SpawnPointMarker::draw(DrawingContext& context)
  43. {
  44. if (Editor::is_active() || g_debug.show_collision_rects)
  45. {
  46. context.color().draw_surface(m_surface, m_col.m_bbox.p1(), LAYER_FOREGROUND1);
  47. }
  48. }
  49. ObjectSettings
  50. SpawnPointMarker::get_settings()
  51. {
  52. ObjectSettings result = MovingObject::get_settings();
  53. result.add_test_from_here();
  54. return result;
  55. }
  56. /* EOF */