text: #ifndef __j1MAP_H__
  #define __j1MAP_H__
  
  #include "PugiXml/src/pugixml.hpp"
  #include "p2List.h"
  #include "p2Point.h"
  #include "j1Module.h"
  
  // ----------------------------------------------------
  
  struct MapLayer
  {
  	p2SString name;
  	uint width;
  	uint height;
  	uint* gid;
  	float speed;
  	bool draw;
  	bool collision;
  	inline uint Get(int x, int y) const
  	{
  		return x + y * width;
  	}
  };
  
  
  
  
  // ----------------------------------------------------
  struct TileSet
  {
  
  	SDL_Rect getTileRect(int id) const;
  
  
  	p2SString			name;
  	int					firstgid;
  	int					margin;
  	int					spacing;
  	int					tile_width;
  	int					tile_height;
  	SDL_Texture*		texture;
  	int					tex_width;
  	int					tex_height;
  	int					num_tiles_width;
  	int					num_tiles_height;
  	int					offset_x;
  	int					offset_y;
  
  };
  
  enum MapTypes
  {
  	MAPTYPE_UNKNOWN = 0,
  	MAPTYPE_ORTHOGONAL,
  	MAPTYPE_ISOMETRIC,
  	MAPTYPE_STAGGERED
  };
  // ----------------------------------------------------
  struct MapData
  {
  	int					width;
  	int					height;
  	int					tile_width;
  	int					tile_height;
  	SDL_Color			background_color;
  	MapTypes			type;
  	p2List<TileSet*>	tilesets;
  
  	p2List<MapLayer*> layers;
  };
  
  // ----------------------------------------------------
  class j1Map : public j1Module
  {
  public:
  
  	j1Map();
  
  	// Destructor
  	virtual ~j1Map();
  
  	// Called before render is available
  	bool Awake(pugi::xml_node& conf);
  
  	// Called each loop iteration
  	void Draw();
  
  	// Called before quitting
  	bool CleanUp();
  
  	// Load new map
  	bool Load(const char* path);
  
  	// Convert to Map
  	iPoint MapToWorld(int x, int y) const;
  	iPoint WorldToMap(int x, int y) const;
  
  	void drawSecretMap();
  	bool colliders = false;
  
  private:
  
  	bool LoadMap();
  	bool LoadTilesetDetails(pugi::xml_node& tileset_node, TileSet* set);
  	bool LoadTilesetImage(pugi::xml_node& tileset_node, TileSet* set);
  	bool LoadLayer(pugi::xml_node& node, MapLayer* layer);
  	bool LoadColliders(pugi::xml_node& node, p2SString object_name);
  
  public:
  
  	MapData data;
  
  private:
  
  	pugi::xml_document	map_file;
  	p2SString			folder;
  	bool				map_loaded;
  };
  
  #endif // __j1MAP_H__