Skip to content

there is a bug #2

@kiyonlin

Description

@kiyonlin

Suppose now that the snake is moving to the "right". I quickly press the "up" and "left" directions keys in the speed time. The direction$ will push the "up" and "left", but withLatestFrom only Taking "Left", "Up" will be ignored, causing the snake to immediately go to the "Left" and collide with itself.

So both ticks$ and direction$ should make the snake moving.

I think change snake$ to be like this will resolve this bug:

let snake$: Observable<Array<Point2D>> = combineLatest(ticks$, direction$).pipe(
    withLatestFrom(snakeLength$, ([_, direction], snakeLength) => [direction, snakeLength]),
    scan(move, generateSnake()),
    share()
  );

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions