Great! you make it by yourself.

It is also possible to do it with just one pair of (if and else) code.
Just shift the origin of your coordinate system.

I will leave it as an exercise for you!  :D