#ifndef MAZEMAP_H #define MAZEMAP_H #include #include #include class MazeMap : public sf::Drawable, public sf::Transformable { public: MazeMap() : width(28), height(31), tileSize(8), texture(nullptr), baseMazeSprite(std::nullopt) {} bool loadMaze(const std::vector& collisionData, const std::vector& pelletData, sf::Texture& sharedTexture, unsigned int tileSize, sf::Vector2u baseMazeTexturePos, sf::Vector2u pelletMazeTexturePos); void eatPellet(int x, int y); bool hasPellet(int x, int y) const; bool isWall(int x, int y) const; int convert2DCoords(int x, int y) const { return x + y * width; } bool isLegalTile(int x, int y) const; unsigned int getWidth() const { return width; } unsigned int getHeight() const { return height; } unsigned int getTileSize() const { return tileSize; } private: void draw(sf::RenderTarget& target, sf::RenderStates states) const override; std::vector collisionMap; // 1=wall, 0=path std::vector pelletMap; // 0=none, 1=pellet, 2=power pellet std::vector pelletEaten; std::optional baseMazeSprite; sf::VertexArray pelletVertices; sf::Texture* texture; unsigned int width; unsigned int height; unsigned int tileSize; sf::Vector2u baseMazeTexPos; sf::Vector2u pelletMazeTexPos; }; #endif