about summary refs log tree commit diff stats
path: root/data/maps/the_great/rooms/Y Room.txtpb
blob: b20420c664dd02dfb8be118b016179de6ae1ec0b (plain) (blame)
1
2
3
4
5
6
name: "Y Room"
display_name: "Question Room"
letters {
  key: "y"
  path: "Components/Collectables/y"
}
String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
#ifndef MAP_H
#define MAP_H

#include <string>
#include <exception>
#include <utility>
#include <list>
#include "object.h"
#include <memory>

const int TILE_WIDTH = 8;
const int TILE_HEIGHT = 8;
const int GAME_WIDTH = 320;
const int GAME_HEIGHT = 200;
const int MAP_WIDTH = GAME_WIDTH/TILE_WIDTH;
const int MAP_HEIGHT = GAME_HEIGHT/TILE_HEIGHT - 1;

class MapLoadException: public std::exception
{
  public:
    MapLoadException(std::string mapname) : mapname(mapname) {}
    
    virtual const char* what() const throw()
    {
      return ("An error occured loading map " + mapname).c_str();
    }
    
  private:
    std::string mapname;
};

class MapWriteException: public std::exception
{
  public:
    MapWriteException(std::string mapname) : mapname(mapname) {}
    
    virtual const char* what() const throw()
    {
      return ("An error occured writing map " + mapname).c_str();
    }
    
  private:
    std::string mapname;
};

struct MapObjectEntry {
  MapObject* object;
  std::pair<double, double> position;
  
  bool operator==(MapObjectEntry& other) const
  {
    return (object == other.object) && (position == other.position);
  }
};

class Map {
  public:
    Map();
    Map(std::string name);
    Map(const Map& map);
    Map(Map&& map);
    ~Map();
    Map& operator= (Map other);
    friend void swap(Map& first, Map& second);
    
    std::string getTitle() const;
    void setTitle(std::string title);
    void save(std::string name);
    bool hasUnsavedChanges() const;
    void setTileAt(int x, int y, int tile);
    int getTileAt(int x, int y) const;
    const std::list<std::shared_ptr<MapObjectEntry>>& getObjects() const;
    void addObject(std::shared_ptr<MapObjectEntry>& obj);
    void removeObject(std::shared_ptr<MapObjectEntry>& obj);
    
  private:
    std::list<std::shared_ptr<MapObjectEntry>> objects;
    int* mapdata;
    std::string title;
    std::string leftmap;
    std::string rightmap;
    bool dirty;
};

#endif