Project_Maat/src/Level.h
Teo-CD d42d176e8d A* implementation
Working except for end of path endless loop (0,0 point appearing in paths for no reason?)

Commit mainly because the HDD is on the verge of dying
2019-06-09 05:18:28 +02:00

52 lines
1.2 KiB
C++

//
// Created by trotfunky on 06/06/19.
//
#ifndef SRC_LEVEL_H
#define SRC_LEVEL_H
#include <SFML/Graphics.hpp>
#include <pugixml.hpp>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include "Utils.h"
#include "Entity.h"
using TextureStore = std::vector<std::unique_ptr<sf::Texture>>;
class Level {
public:
Level(const pugi::xml_document& xmlDoc, const TextureStore& textureStore);
void render(sf::RenderWindow& renderWindow) const;
void runStep();
private:
const pro_maat::GridPos size;
std::vector<Entity> entities;
const TextureStore& textures;
//
// Pathfinding
//
std::vector<pro_maat::GridPos> occupiedSquares;
/// If sign is +1, finds a path between start and goal positions.
/// If sign is -1, finds a path away from the goal position, from the starting position.
/// THIS DOES NOT HANDLE ENTITIES BIGGER THAN ONE SQUARE
///
/// \param start Starting position
/// \param goal Goal position
/// \param sign +1 or -1, defines if we go towards or away from the goal
/// \return Orientation of the next move if successful, Orientation::None otherwise.
Orientation findPath(pro_maat::GridPos start, pro_maat::GridPos goal, int sign);
};
#endif //SRC_LEVEL_H