shivangg / snakeGame

The classic snake game using ReactJS

Home Page:https://shivangg.github.io/snakeGame/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Snake wrongly eats itself

shivangg opened this issue · comments

The snake dies when the opposite direction arrow key( w.r.t. snake current direction ) is pressed immediately after non-opposite arrow key. This is because the game is not effectively ignoring the opposite arrow keys. Shift the ignore mechanics from Game component to SnakeBody component so that the ignore check is done on every update of the snake state.