StateMap.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include "StateMap.h"
  2. #include "Graphics.h"
  3. #include "render/Text.h"
  4. #include "piaf/Archive.h"
  5. using WalrusRPG::States::StateMap;
  6. using namespace WalrusRPG;
  7. using namespace WalrusRPG::Graphics;
  8. using WalrusRPG::Utils::Rect;
  9. using WalrusRPG::PIAF::Archive;
  10. using WalrusRPG::PIAF::File;
  11. using WalrusRPG::Graphics::Texture;
  12. using WalrusRPG::Graphics::Font;
  13. namespace
  14. {
  15. void print_debug_camera_data(const Camera &camera, const Font &fnt)
  16. {
  17. fnt.draw_format(240, 1, Black, "CAM : X : %d Y: %d", camera.get_x(),
  18. camera.get_y());
  19. fnt.draw_format(240, 0, "CAM : X : %d Y: %d", camera.get_x(), camera.get_y());
  20. }
  21. void print_debug_map_data(const Map &map, const Font &fnt)
  22. {
  23. fnt.draw_format(240, 9, Black, "MAP : W: %d, H:%d", map.get_width(),
  24. map.get_height());
  25. fnt.draw_format(240, 8, "MAP : W: %d, H:%d", map.get_width(), map.get_height());
  26. }
  27. }
  28. // TODO : We definitely need a Resource Manager
  29. StateMap::StateMap(int x, int y, Map &map)
  30. : camera(x, y), map(map), data("data/out.wrf"), tex_haeccity(data.get("t_haeccity")),
  31. txt(tex_haeccity, data.get("f_haeccity"))
  32. {
  33. }
  34. void StateMap::update(unsigned dt)
  35. {
  36. camera.update(dt);
  37. }
  38. void StateMap::render(unsigned dt)
  39. {
  40. // fill(Black);
  41. map.render(camera, dt);
  42. print_debug_camera_data(camera, txt);
  43. print_debug_map_data(map, txt);
  44. }