Skip to content

Move action delay #8

@Kif11

Description

@Kif11

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions