Thank you for your answers,
I'd like to find the bug myself, but this is quite hard for me.
I tested much things and already found something anyway, but i don't understand why it happens :
Here are my two main classes, character and zombie (zombie extending the first one) :
class Character : public Transformable
{
public :
int speed;
int width;
bool stuck;
e_direction direction;
bool deplacement;
bool selected;
bool hovered;
Vector2i aim_position;
Texture char_texture, collision_texture, collision_texture_large;
Sprite char_sprite, collision_sprite, collision_sprite_large;
CircleShape circle,circle_hover;
bool draw_circle;
int move_delay;
Vector2f temp_aim_position;
deque<Vector2f> path;
Character()
{
setPosition(Vector2f(rand()%300+400, rand()%300+300));
//setPosition(Vector2f(30,620));
char_texture.loadFromFile("character.png");
char_sprite.setTexture(char_texture);
char_sprite.setOrigin(CHARWIDTH,CHARHEIGHT);
char_sprite.setPosition(getPosition());
circle.setPosition(getPosition());
circle.setOrigin(CHARWIDTH, CHARHEIGHT);
circle.setFillColor(Color(0,255,255,0));
circle.setRadius(15);
circle.setOutlineColor(Color(0,255,24,255));
circle.setOutlineThickness(3);
circle_hover=circle;
circle_hover.setOutlineColor(Color(200,255,24,255));
circle_hover.setOrigin(CHARWIDTH, CHARHEIGHT);
CreateTextureAndBitmask(collision_texture, "collision_circle.png");
collision_sprite.setTexture(collision_texture);
collision_sprite.setOrigin(10, 10);
collision_sprite.setPosition(getPosition());
CreateTextureAndBitmask(collision_texture_large, "collision_circle_large.png");
collision_sprite_large.setTexture(collision_texture_large);
collision_sprite_large.setOrigin(CHARWIDTH, CHARHEIGHT);
collision_sprite_large.setPosition(getPosition());
speed=1;
deplacement=false;
selected=false;
draw_circle=false;
hovered=false;
direction=Droite;
move_delay=0;
stuck=false;
}
};
class Zombie : public Character
{
public:
vector<int> cibles;
bool chasing;
float range;
int chasing_timer;
Zombie()
{
Zombie::Character();
char_texture.loadFromFile("ennemy.png");
char_sprite.setTexture(char_texture);
range=100;
setPosition(Vector2f(rand()%300+1000, rand()%300+300));
//setPosition(Vector2f(700,420));
char_sprite.setPosition(getPosition());
collision_sprite.setPosition(getPosition());
chasing=false;
chasing_timer=0;
}
};
My program is crashing on exit if i use the searching function
for a character type (and works properly if i use it for a zombie type, which extends character:
Here is the prototype of the function, and its call:
//Prototype
void search(node*** matrix, deque<node>* n, deque<node>* m, Sprite collision_map, Sprite collision_sprite_large, Vector2f position, Vector2f aim,
Character* entite, int index, Character* tab_entite, vector<Building*>* batiments, grid_node** grid_bg)
//Call for character type (make the program crashing at exit)
search(matrix, tree, tree_to_sort, collision_map, entite[i]->collision_sprite_large, entite[i]->getPosition(),
Vector2f(entite[i]->aim_position.x, entite[i]->aim_position.y), entite[i], i, *entite, batiments, grid_bg);
//Call for zombie type (make the program exiting properly)
search(matrix, tree, tree_to_sort, collision_map, zombies[i]->collision_sprite_large, zombies[i]->getPosition(),
Vector2f(zombies[i]->aim_position.x, zombies[i]->aim_position.y), zombies[i], i, *zombies, batiments, grid_bg);
I really don't get it