You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

79 lines
1.9 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2013 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://www.wtfpl.net/ for more details.
  9. //
  10. //
  11. // The TileSet class
  12. // -----------------
  13. // A TileSet is a collection of tiles stored in a texture. Texture uploading
  14. // and freeing is done in the render tick method. When the refcount drops to
  15. // zero, the texture is freed.
  16. //
  17. #if !defined __LOL_TILESET_H__
  18. #define __LOL_TILESET_H__
  19. #include <stdint.h>
  20. #include "entity.h"
  21. namespace lol
  22. {
  23. class TileSetData;
  24. class TileSet : public Entity
  25. {
  26. public:
  27. TileSet(char const *path);
  28. TileSet(char const *path, Image* image);
  29. virtual ~TileSet();
  30. /* Old style: path to PNG file */
  31. TileSet(char const *path, ivec2 size, ivec2 count);
  32. TileSet(char const *path, Image* image, ivec2 size, ivec2 count);
  33. /* Inherited from Entity */
  34. virtual char const *GetName();
  35. protected:
  36. virtual void TickDraw(float seconds, Scene &scene);
  37. public:
  38. /* New methods */
  39. int AddTile(ibox2 rect);
  40. void AddTile(ivec2 count);
  41. int GetTileCount() const;
  42. ivec2 GetTileSize(int tileid) const;
  43. Texture * GetTexture();
  44. Texture const * GetTexture() const;
  45. Image * GetImage();
  46. Image const * GetImage() const;
  47. void SetPalette(TileSet* palette);
  48. TileSet* GetPalette();
  49. TileSet const * GetPalette() const;
  50. ivec2 GetTextureSize() const;
  51. void Bind();
  52. void Unbind();
  53. void BlitTile(uint32_t id, vec3 pos, int o, vec2 scale, float angle,
  54. vec3 *vertex, vec2 *texture);
  55. private:
  56. void Init(char const *path);
  57. void Init(char const *path, Image* image);
  58. TileSetData* m_data;
  59. TileSet* m_palette;
  60. };
  61. } /* namespace lol */
  62. #endif // __LOL_TILESET_H__