#pragma once
#include<SFML/Graphics.hpp>
#include "AreaMap.h"
#include "Types.h"
class Entity
{
public:
std::string name;
int type;
sf::Sprite icon;
int id;
Coor coor;
void setIcon(sf::Texture* texture);
Entity();
virtual ~Entity();
};
There's no way 625 elements exceeds whatever that gigantic number is and I've used that entity class in other parts of the program with no problem. Any idea what the problem might be?
AreaMap.h and Entity.h are including each other. The preprocessor can't resolve inclusion cycles, so you'll invariably be left with an invalid translation unit.
It looks to me like Entity.h doesn't need to include AreaMap.h.
Is an array of vectors really the data structure you want to use?
Thanks! I'll have to watch for those unnecessary includes.
I've actually been pondering if arrays are best way to go for map tiles. The only other way I can think of to do it is to just have a big list of objects and their coordinates and search through the whole list to find the ones at a particular set of coordinates.
So I assume each cell can contain more than one Entity. In that case it's fine, but you should have a MapCell (or whatever) class that contains whatever data a cell needs.
is that entity pointer one entity, or possibly a block of them?
if its just the one entity, the vector isnt doing anything, you may as well just have a 2d array of entity *s.
... it seems to me that an area would be cut up into grids and each cell would have one and only one texture. Since cells in many programs may reuse the same texture, a pointer back to one copy of it makes sense to me.
break apart what you have and 'rubber duck' explain what each piece is doing (esp that vector).
Thanks! I'll have to watch for those unnecessary includes
If the extra files are creating problems rather than solving them, you have too many. Consider creating fewer files, especially if your program is currently small or you are currently the only programmer.