Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

59 строки
1.3 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the Do What The Fuck You Want To
  7. // Public License, Version 2, as published by Sam Hocevar. See
  8. // http://sam.zoy.org/projects/COPYING.WTFPL for more details.
  9. //
  10. #if defined HAVE_CONFIG_H
  11. # include "config.h"
  12. #endif
  13. #include <cstdlib>
  14. #include "core.h"
  15. Layer::Layer(int w, int h, int z, int o, uint32_t *in_data)
  16. {
  17. width = w;
  18. height = h;
  19. altitude = z;
  20. orientation = o;
  21. data = in_data;
  22. #if 0
  23. fread(data, sizeof(unsigned int), width * height, fp);
  24. for (int n = 0; n < width * height; n++)
  25. {
  26. unsigned int i = data[n];
  27. // XXX: endianness swapping might be necessary here
  28. data[n] = i ? i - 1 : 0;
  29. }
  30. #endif
  31. }
  32. Layer::~Layer()
  33. {
  34. free(data);
  35. }
  36. void Layer::Render(int x, int y, int z)
  37. {
  38. Scene *scene = Scene::GetDefault();
  39. for (int j = 0; j < height; j++)
  40. for (int i = 0; i < width; i++)
  41. if (data[j * width + i])
  42. scene->AddTile(data[j * width + i],
  43. x + i * 32, y + j * 32 - altitude,
  44. altitude + z, orientation);
  45. }
  46. int Layer::GetZ()
  47. {
  48. return altitude;
  49. }