flip_level_transformer.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 "supertux/flip_level_transformer.hpp"
  17. #include "badguy/badguy.hpp"
  18. #include "object/block.hpp"
  19. #include "object/camera.hpp"
  20. #include "object/decal.hpp"
  21. #include "object/flower.hpp"
  22. #include "object/platform.hpp"
  23. #include "object/player.hpp"
  24. #include "object/tilemap.hpp"
  25. #include "supertux/sector.hpp"
  26. void
  27. FlipLevelTransformer::transform_sector(Sector& sector)
  28. {
  29. float height = sector.get_height();
  30. for (auto& object : sector.get_objects()) {
  31. object->on_flip(height);
  32. }
  33. sector.get_camera().reset(sector.get_players()[0]->get_pos());
  34. }
  35. void
  36. FlipLevelTransformer::transform_flip(Flip& flip)
  37. {
  38. if (flip & VERTICAL_FLIP) {
  39. flip = flip & ~VERTICAL_FLIP;
  40. } else {
  41. flip = flip | VERTICAL_FLIP;
  42. }
  43. }
  44. /* EOF */