snake movement logic