I'm using SFML library for a game application with moving objects. In the game, I have a ball object and I need to make sure that the ball's offset on the Y-axis each move is at least 0.1 (or -0.1)
Here's the code I'm using now:
if (offset.y < 0.0 && offset.y > -0.1) offset.y = -0.1;
if (offset.y > 0.0 && offset.y < 0.1) offset.y = 0.1;
Is there an easier/prettier way to accomplish that?
Edit: As pointed out by the comments, code should include 0.0 case
if (offset.y < 0.0 && offset.y > -0.1) offset.y = -0.1;
if (offset.y >= 0.0 && offset.y < 0.1) offset.y = 0.1;