If I’m on a cell A going to cell B. While still on A I press UP the snake doesn’t go UP form A it goes to B first then UP.
This is happening because previous nextSnake doesn't receive update moves.
To fix:
const next = state => {
return {
rows: state.rows,
cols: state.cols,
moves: nextMoves(state),
- snake: nextSnake(state),
+ snake: nextSnake({...state, moves: nextMoves(state)}),
apple: nextApple(state)
}
}
This is improve reaction to key presses and make game feels less sluggish.
If I’m on a cell A going to cell B. While still on A I press UP the snake doesn’t go UP form A it goes to B first then UP.
This is happening because previous
nextSnakedoesn't receive updatemoves.To fix:
const next = state => { return { rows: state.rows, cols: state.cols, moves: nextMoves(state), - snake: nextSnake(state), + snake: nextSnake({...state, moves: nextMoves(state)}), apple: nextApple(state) } }This is improve reaction to key presses and make game feels less sluggish.