text: #ifndef __j1MAP_H__
  #define __j1MAP_H__
  
  #include "PugiXml/src/pugixml.hpp"
  #include "p2List.h"
  #include "p2Point.h"
  #include "j1Module.h"
  
  class Entity;
  
  // TODO 1: Create a struct for the map layer
  struct MapLayer
  {
  	p2SString			name = nullptr;
  	unsigned int		width = 0;
  	unsigned int		height = 0;
  
  	uint*				gid = nullptr;
  
  	uint GetGid(int x, int y)const
  	{
  		return gid[y*width + x];
  	}
  };
  // ----------------------------------------------------
  
  	// TODO 6: Short function to get the value of x,y
  
  
  
  // ----------------------------------------------------
  struct TileSet
  {
  	// TODO 7: Create a method that receives a tile id and returns it's Rectfind the Rect associated with a specific tile id
  	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;
  	// TODO 2: Add a list/array of layers to the map!
  };
  
  // ----------------------------------------------------
  class j1Map : public j1Module
  {
  public:
  
  	j1Map();
  
  	// Destructor
  	virtual ~j1Map();
  
  	// Called before render is available
  	bool Awake(pugi::xml_node& conf);
  
  	//Start
  	bool Start();
  
  	// Called each loop iteration
  	void Draw(float dt);
  	bool LoadEntities();
  	
  
  	// Called before quitting
  	bool CleanUp();
  
  	// Load new map
  	bool Load(const char* path);
  	void UnloadMap();
  		
  	// TODO 8: Create a method that translates x,y coordinates from map positions to world positions
  	iPoint MapToWorld(int x, int y) const;
  	iPoint WorldToMap(int x, int y) const;
  
  	//Colisions
  	
  	bool IsWalkable(Entity* entity);
  	bool IsFallable(Entity* entity);
  		
  private:
  
  	bool LoadMap();
  	bool LoadTilesetDetails(pugi::xml_node& tileset_node, TileSet* set);
  	bool LoadTilesetImage(pugi::xml_node& tileset_node, TileSet* set);
  	// TODO 3: Create a method that loads a single laye
  	bool LoadLayer(pugi::xml_node& node, MapLayer* layer);
  
  public:
  
  	MapData				data;
  	float				cloud_parallax = 0.0f;
  	MapLayer*			pathfinding = nullptr;
  
  	//LOGIC LAYER
  	bool				logic = false;
  
  private:
  
  
  	pugi::xml_document	map_file;
  	pugi::xml_node		map_node;
  	p2SString			folder;
  	bool				map_loaded = false;
  	
  };
  
  #endif // __j1MAP_H__