Map.h 630 B

1234567891011121314151617181920212223
  1. #ifndef MAP_H
  2. #define MAP_H
  3. #include "Position.h"
  4. #include "Tile.h"
  5. struct Map final {
  6. // OK is 0 to allow interpreting the enum as bool
  7. enum LoadResult { OK, FILE_NOT_FOUND, INVALID_FILE_FORMAT };
  8. // returns the tile at the given position or a null tile if the position is
  9. // not valid
  10. const Tile& getTile(const Position& p) const;
  11. // returns the width of the map, 0 is no map is loaded
  12. int getWidth() const;
  13. // return the hight of the map, 0 is no map is loaded
  14. int getHeight() const;
  15. // loads a map from a file and returns the result
  16. LoadResult load(const char* path);
  17. };
  18. #endif