I have a variable (1) that is either < 0 or 0 >. That value should be added to another value (2) when value (1) is > 0. However value (2) should be subtract by value (1) if that value is < 0, of course making value (1) positive when subtracting. My code looks like this:
positionRandomButton = CGPoint(x: CGFloat(randomXValue) + card.position.x, y: CGFloat(randomYValue) + card.position.y)
Here randomXValue and randomYValue can be that value (1). Now it always adds be, despised value (1) can be < 0. I can solve this by making four if cases, but I think there should be a better method. the +'s you see in the code should change accordingly, or something else should happen. Thanks.