Skip to content

Diagonal / inconsistent movement when multiple direction flags are true #28

@Zsozsiii

Description

@Zsozsiii

If more than one direction flag (leftDirection, rightDirection, upDirection, downDirection) is true at the same time, the snake movement becomes inconsistent and can effectively behave like a diagonal move.
Under fast consecutive key presses, more than one direction flag can end up being true. In those cases, the move() method applies multiple updates in a single tick, which causes the head to move in an unexpected direction (a combination of the active flags), instead of following only the last valid direction.
At any given game tick exactly one direction should be active, and the snake should move only in that single direction (the last valid direction pressed by the player). Multiple direction flags being true simultaneously should never result in a combined or diagonal movement.

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