A 2D tile-based sandbox game.
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.

Tile.h 660B

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma once
  2. #include <stdint.h>
  3. #include <string>
  4. #include <optional>
  5. #include <memory>
  6. #include "Resource.h"
  7. namespace Swan {
  8. struct Tile {
  9. public:
  10. using ID = uint16_t;
  11. struct Builder {
  12. std::string name;
  13. std::string image;
  14. bool isSolid = true;
  15. float lightLevel = 0;
  16. std::optional<std::string> droppedItem = std::nullopt;
  17. };
  18. const ID id;
  19. const std::string name;
  20. const bool isSolid;
  21. const float lightLevel;
  22. const std::optional<std::string> droppedItem;
  23. Tile(ID id, std::string name, const Builder &builder):
  24. id(id), name(name),
  25. isSolid(builder.isSolid), lightLevel(builder.lightLevel),
  26. droppedItem(builder.droppedItem) {}
  27. };
  28. }