0

What does this code means? i mean why y++ coordinate going down if the value of y is increasing vice-versa!

{ head.direction=key; if(key==UP) head.y--; if(key==DOWN) head.y++; }

5th Jan 2019, 4:44 PM
rahul negi
rahul negi - avatar
1 Answer
+ 4
Coordinates starts from upper left corner, the upper left coordinate are (0,0), this way to move up we subtract y, to move down increase y, to move left decrease x, and to move right increase x. Hth, cmiiw
5th Jan 2019, 5:10 PM
Ipang