Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

91 linhas
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. void MapViewer::TickGame(float deltams)
  40. {
  41. Entity::TickGame(deltams);
  42. }
  43. void MapViewer::TickDraw(float deltams)
  44. {
  45. Entity::TickDraw(deltams);
  46. GetScene();
  47. data->map->Render(data->scene, -data->povx, -data->povy, 0);
  48. data->scene->Render();
  49. delete data->scene;
  50. data->scene = NULL;
  51. }
  52. Scene *MapViewer::GetScene()
  53. {
  54. if (!data->scene)
  55. data->scene = new Scene();
  56. return data->scene;
  57. }
  58. int MapViewer::GetWidth()
  59. {
  60. return data->map->GetWidth();
  61. }
  62. int MapViewer::GetHeight()
  63. {
  64. return data->map->GetHeight();
  65. }
  66. void MapViewer::SetPOV(int x, int y)
  67. {
  68. data->povx = x;
  69. data->povy = y;
  70. }