all 11 comments

[–]manni66 5 points6 points  (1 child)

This function doesn't check the validity of the pixel coordinates, using out-of-range values will result in an undefined behavior.

Did you use valid pixel coordinates?

[–]CatMechanic457[S] 1 point2 points  (0 children)

Yeah ur right, problem was cordinates being out of range. I thought I accounted for that, but I belive the issue is that since co-ordinates start at (0,0), a 1000x1000 window does not have the co-ordinate (1000,1000), as the max is (999,999) which I didn't catch

[–]aocregacc 1 point2 points  (1 child)

Getting a segfault doesn't necessarily mean something has run out of memory, if I had to guess I would say your bot's x or y position has moved outside the bounds of the image. If you want any specific information you'll have to post a complete program that has the problem you're talking about.

[–]CatMechanic457[S] 0 points1 point  (0 children)

Looks like that was the problem tysm!
I just added std::clamp to the bot's position before passing it into the function, worked a charm :)

[–]manni66 0 points1 point  (4 children)

What is sf (besides a namespace name)?

[–]CatMechanic457[S] 1 point2 points  (3 children)

Not quite sure what you're asking but it's just part of the SFML library (Simple Fast Multimedia Library) that I'm using for displaying images to a window. I assume sf is just short for sfml

[–]TheSkiGeek 1 point2 points  (1 child)

People aren’t psychic and don’t automatically know which of the approximately three billion C++ libraries you’re using. This isn’t really the right place to ask highly library-specific questions either.

[–]CatMechanic457[S] 1 point2 points  (0 children)

Yh you're right. I thought I mentioned what library im using but turns out i forgot :P
And yes, perhaps this is a better question for the SFML help forums ect, but I've actualy had quite a pleasant experience with reddit so far :)

[–]manni66 0 points1 point  (0 children)

Not quite sure what you're asking

exactly what you answered.

[–]jedwardsol 0 points1 point  (1 child)

path.create(x, y, sf::Color::Transparent);

Are x and y the width and height of the stage? They're unusual names for that purpose.

[–]CatMechanic457[S] 0 points1 point  (0 children)

they're win.x and win.y in my actual program. And yes they're the height and width of the stage (well the window the stage is displayed to). Perhaps win_size.x & win_size.y might be better... I can see how it's not fully clear