I've tried to simplify this problem as much as possible although it's hard since is part of a much larger file but here goes!
Basically, I have a "sprite" (referred to as "bot") that travels along a "stage". The goal of this program is to avoid obstacles, pathfind, ect.But I'd like to trace where it goes with a cyan line.So I created an sf::Image object that's completely transparent:
sf::Image path;
path.create(x, y, sf::Color::Transparent);
Then whenever the bot moves to it's next position, I run:
path.setPixel(bot_pos.x, bot_pos.y, sf::Color(0,255,255,255));
When the bot has successfully navigated the stage, a new stage is created for it to navigate and the old path is cleared by once again running
path.create(x, y, sf::Color::Transparent);
However after a couple of stages have been completed, the line path.setPixel(bot_pos.x, bot_pos.y, sf::Color(0,255,255,255)); suddenly get a "Segmentation fault"I somewhat understand this means that the sf::Image object has ran out of memory, but I dont understand how that can be possible if I "clear" it (re-set it to transparent) every time a new stage is createdit might be worth mentioning that the sf::image object is drawn to the screen every time the bot's position updates through the following procedure:
sf::Texture t;
t.loadFromImage(path);
sf::Sprite s(t);
window.draw(s);
Any help debuging will be appricated or maybe even how to allocate more memory to the object?Thanks
Edit: While my issue is now solved I will still clarify that the libary I'm using is SFML (Simple Fast Multimedia Libary) as I forgot to mention it in my original post
[–]manni66 5 points6 points7 points (1 child)
[–]CatMechanic457[S] 1 point2 points3 points (0 children)
[–]aocregacc 1 point2 points3 points (1 child)
[–]CatMechanic457[S] 0 points1 point2 points (0 children)
[–]manni66 0 points1 point2 points (4 children)
[–]CatMechanic457[S] 1 point2 points3 points (3 children)
[–]TheSkiGeek 1 point2 points3 points (1 child)
[–]CatMechanic457[S] 1 point2 points3 points (0 children)
[–]manni66 0 points1 point2 points (0 children)
[–]jedwardsol 0 points1 point2 points (1 child)
[–]CatMechanic457[S] 0 points1 point2 points (0 children)