I have got a function in sfml which gets the co-ordinates of a rectangle bounding box for a circle shape. The return value is described as FloatRect and the value is:
circle1 = 1026324980834960100
This is for a circle with the following dimensions:
circle1
x = 395.11
y = 344.97
width = 49.78
height = 50.06
I may be being stupid but I have tried looking in all the ref books I can find and I still can't work out what the return value has got to do with the 4 co-ordinates.
A FloatRect has 4 members. It does not have a value, per se. The values it holds are contained in its data members.
I may be being stupid but I have tried looking in all the ref books I can find and I still can't work out what the return value has got to do with the 4 co-ordinates.
What return value and what 4 coordinates? width/height are not coordinates.
If you could supply some minimal code that reproduced the situation you are speaking about instead of using English mumbo jumbo, that would be helpful.
I think you are confused, at least I think I am. (You should supply code that shows us 1026324980834960100)
How did you get that value? Did you just directly std::cout << the floatrect? width/height are not coordinates, but top and left are. You can thus get the other corners by decrementing top by height, incrementing left by width and doing both for the bottom right corner.
I then use this to find out whether the mouse is within that box area, in order to drag and drop. The actual program works fine. What I would like to do is cut these 4 lines down into a single one, if possible. I am fairly new to this so I hope you will bear with me.
The sprintf call is undefined behavior. An sf::FloatRect is not a float.
The following line is equivalent to: (std::cout << buffer), "\n" ; which is to say that the "\n" is pointless. Use std::cout << buffer << '\n'; to chain calls to operator<<.
Using events is more appropriate for dragging/dropping stuff than using sf::Mouse.