This is a rather simple question.
I'm writing a computer program, and I have a variable for velocity, which takes values $\pm 1$. I also have corresponding sprites, facing both right and left, on rows 0 and 1 of a spritesheet. Funny enough, I got the rows on the sheet backwards, so the leftwards is in the first row, and rightwards in the second row. What I'm trying to do is map -1 to 1 and 1 to 0.
So my question is: is there a simple function $f$ constructed from standard computer math like addition, subtraction, multiplication, division, exponentiation, absolute value, floors and ceilings that satisfies $f(-1) = 1$ and $f(1) = 0$.
We have the points $(-1,1)$ and $(1,0)$. We can simply construct the line that goes through these points:
$y=\frac{1-x}{2}$
Does that work for your purposes?