75 行
1.3 KiB

  1. //
  2. // Deus Hax (working title)
  3. // Copyright (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
  4. //
  5. #if defined HAVE_CONFIG_H
  6. # include "config.h"
  7. #endif
  8. #include <cstdio>
  9. #include <cmath>
  10. #include "core.h"
  11. #include "debugboard.h"
  12. /*
  13. * DebugBoard implementation class
  14. */
  15. class DebugBoardData
  16. {
  17. friend class DebugBoard;
  18. private:
  19. Game *game;
  20. int tiler;
  21. float x, y, z;
  22. };
  23. /*
  24. * Public DebugBoard class
  25. */
  26. DebugBoard::DebugBoard(Game *game)
  27. {
  28. data = new DebugBoardData();
  29. data->game = game;
  30. Ticker::Ref(game);
  31. data->tiler = Tiler::Register("monsterz/tiles.png", 48);
  32. data->x = 32;
  33. data->y = 0;
  34. data->z = 112;
  35. }
  36. void DebugBoard::TickGame(float deltams)
  37. {
  38. Entity::TickGame(deltams);
  39. }
  40. void DebugBoard::TickDraw(float deltams)
  41. {
  42. Entity::TickDraw(deltams);
  43. int x = data->x;
  44. int y = data->y;
  45. int z = data->z;
  46. for (int j = 0; j < 8; j++)
  47. for (int i = 0; i < 8; i++)
  48. {
  49. int id = 28 + ((i + 3) * (j + 1) % 10) * 3 + ((i ^ (j + 2)) % 5);
  50. id += (id % 5) / 4;
  51. data->game->GetScene()->AddTile((data->tiler << 16) | id,
  52. x + i * 48 - 16, y + j * 48, z, 1);
  53. }
  54. }
  55. DebugBoard::~DebugBoard()
  56. {
  57. Ticker::Unref(data->game);
  58. Tiler::Deregister(data->tiler);
  59. delete data;
  60. }