> What does this line/code means?

What does this line/code means?

Posted at: 2014-12-18 
Just inside the parentheses:

If dir equals 1 then it's1, otherwise it's -1

=================================

a = 2

b = (a < 5 ? 100 : 200)

Since 2<5, b is assigned the value 100

=================================

a = 7

b = (a < 5 ? 100 : 200)

Since 7 is NOT <5, b is assigned the value 200

its testing if the variable (dir) is equal to 1 or 2 and it made a new variabe (DX) which is %2 of dir. im not sure what that part means. thats some weird code bro, im used to C++ and java

please tell what does this line means in simple java or C# terms

int dir = 1;

int dx = dir % 2 ? (dir == 1 ? 1 : - 1) : 0;

int dy = dir % 2 == 0 ? (dir == 2 ? 1 : - 1) : 0;

i cannot understand this ? (dir == 1 ? 1 : - 1) : 0;

pls anyone tell as soon as possible

thanks