選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

96 行
1.3 KiB

  1. //
  2. // Deus Hax (working title)
  3. // Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
  4. //
  5. #if defined HAVE_CONFIG_H
  6. # include "config.h"
  7. #endif
  8. #include <cstdio>
  9. #include "core.h"
  10. /*
  11. * MapViewer implementation class
  12. */
  13. class MapViewerData
  14. {
  15. friend class MapViewer;
  16. private:
  17. Map *map;
  18. int x, y;
  19. int povx, povy;
  20. int done;
  21. Scene *scene;
  22. };
  23. /*
  24. * Public MapViewer class
  25. */
  26. MapViewer::MapViewer(char const *mapname)
  27. {
  28. data = new MapViewerData();
  29. data->map = new Map(mapname);
  30. data->x = data->y = 0;
  31. data->done = 0;
  32. data->scene = NULL;
  33. }
  34. MapViewer::~MapViewer()
  35. {
  36. delete data->map;
  37. delete data;
  38. }
  39. Entity::Group MapViewer::GetGroup()
  40. {
  41. return Entity::GetGroup();
  42. }
  43. void MapViewer::TickGame(float deltams)
  44. {
  45. Entity::TickGame(deltams);
  46. }
  47. void MapViewer::TickDraw(float deltams)
  48. {
  49. Entity::TickDraw(deltams);
  50. GetScene();
  51. data->map->Render(data->scene, -data->povx, -data->povy, 0);
  52. data->scene->Render();
  53. delete data->scene;
  54. data->scene = NULL;
  55. }
  56. Scene *MapViewer::GetScene()
  57. {
  58. if (!data->scene)
  59. data->scene = new Scene();
  60. return data->scene;
  61. }
  62. int MapViewer::GetWidth()
  63. {
  64. return data->map->GetWidth();
  65. }
  66. int MapViewer::GetHeight()
  67. {
  68. return data->map->GetHeight();
  69. }
  70. void MapViewer::SetPOV(int x, int y)
  71. {
  72. data->povx = x;
  73. data->povy = y;
  74. }