Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Noticeable input lag. #22

Open
joereynolds opened this issue May 7, 2016 · 6 comments
Open

Noticeable input lag. #22

joereynolds opened this issue May 7, 2016 · 6 comments

Comments

@joereynolds
Copy link

joereynolds commented May 7, 2016

If you do down + right (or any combination really) multiple times, you can see that snake will still be doing those movements even after you've finished typing. I'm assuming this is because it's gridded rather than just a free amount of pixels but still...

@patorjk
Copy link
Owner

patorjk commented May 9, 2016

This is because the game queues key presses. If key presses aren't queued, you can miss some (ex: someone can press down + right really quickly and only go down because the game wasn't ready for the next key press. This would lead the snake into not going right and make the player feel like the game didn't register their right key press). However, I can see how it would cause the lag effect if down+right were pressed repeatedly really quickly. I'll have to think about this, not sure what the best solution would be.

@joereynolds
Copy link
Author

In that case I think the real question is, how is it missing/discarding keypresses?

@patorjk
Copy link
Owner

patorjk commented May 10, 2016

The snakeSpeed determines the rate of how fast the snake moves. At each tick the game checks to see which direction it will move. The direction the snake moves is based on the arrow keys, when an arrow key is typed the direction is changed. If the user presses two keys within the snakeSpeed time period / tick period (ex: right+down), then only the last key will register if queuing isn't done.

@samkcarlile
Copy link

I have an idea that may work. How about attaching a time with each move in the queue and then for every tick, checking whether too much (this could be defined) time has passed to actually execute the move. That way if one was to press multiple arrow keys in a small amount of time, there wouldn't be 'residual moves' per se if the move is too old.

@patorjk
Copy link
Owner

patorjk commented May 11, 2016

That's an interesting idea, thank you Sam. When I get a chance in the next few days I'll try and dive into this deeper.

@Coteh
Copy link
Contributor

Coteh commented Oct 18, 2019

@dginovker was telling me that #56 fixes this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants