No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

62 líneas
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 "core.h"
  14. /*
  15. * Tiler implementation class
  16. */
  17. static class TilerData
  18. {
  19. friend class Tiler;
  20. public:
  21. Dict tilesets;
  22. }
  23. tilerdata;
  24. static TilerData * const data = &tilerdata;
  25. /*
  26. * Public Tiler class
  27. */
  28. int Tiler::Register(char const *path, int w, int h, float dilate)
  29. {
  30. int id = data->tilesets.MakeSlot(path);
  31. if (!data->tilesets.GetEntity(id))
  32. {
  33. TileSet *tileset = new TileSet(path, w, h, dilate);
  34. data->tilesets.SetEntity(id, tileset);
  35. }
  36. return id + 1; /* ID 0 is for the empty tileset */
  37. }
  38. void Tiler::Deregister(int id)
  39. {
  40. data->tilesets.RemoveSlot(id - 1); /* ID 0 is for the empty tileset */
  41. }
  42. void Tiler::BlitTile(uint32_t code, int x, int y, int z, int o)
  43. {
  44. int id = (code >> 16) - 1; /* ID 0 is for the empty tileset */
  45. TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id);
  46. tileset->BlitTile(code & 0xffff, x, y, z, o);
  47. }