25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

tileset.h 1.7 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. protected:
  34. /* Inherited from Entity */
  35. virtual char const *GetName();
  36. virtual void TickDraw(float seconds);
  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. ivec2 GetTextureSize() const;
  46. void Bind();
  47. void Unbind();
  48. void BlitTile(uint32_t id, vec3 pos, int o, vec2 scale, float angle,
  49. vec3 *vertex, vec2 *texture);
  50. private:
  51. void Init(char const *path);
  52. void Init(char const *path, Image* image);
  53. TileSetData *m_data;
  54. };
  55. } /* namespace lol */
  56. #endif // __LOL_TILESET_H__