Preventing Food Object to apear over snake

what should be the logic:-
*to prevent object formation over snake
*to prevent snake going backward
and
*to prevent snake colliding with its own body

Hey @anitish.225
Hope you are enjoying the course buddy

  1. You can check if the apple co-ordinates coincide with snake coordinates by simple array traversal or for more efficient implementation try using a set to store co-ordinates and perform checks in 0(1)
  2. You can check if input direction is opposite of current direction since you already know current direction, simple if check
  3. Again you can actually write a logic to check if a new cell is coinciding with the snake body by array traversal or set logic and perform the necessary operations
    Happy Coding !!

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

Exipure South Africa: Reducing weight is definitely not easy because there are some of the other hurdles that keep arising on the way. Exipure South Africa is the best alternative that keeps you away from unhealthy diet plans and encourages a complete weight reduction.