snake icon indicating copy to clipboard operation
snake copied to clipboard

Pressing an arrow key in the opposite direction stops the game

Open lydell opened this issue 9 years ago • 2 comments

Example steps to reproduce:

  1. Press the left arrow key when the game starts.

Actual result: The game stops. Expected result: The game continues as if no key was pressed at all.

I find myself pressing the wrong keys by mistake a lot, so to me the game isn't really playable. Nevertheless, impressive golfing!

lydell avatar Jun 28 '16 17:06 lydell

Thanks.

One simple and short ( 2 bytes ) way to work around the problem is to switch from directional to steering controls so that only the ← and → keys are needed.

This is done by replacing d=e.keyCode&3 with d=d-e.keyCode&3

But directional controls don't need any explanation and this other controls scheme takes more practice to master.

What do you think ?

p01 avatar Jun 28 '16 19:06 p01

I know that some Snake versions do have steering controls, but I've never played one. I guess I'd suck at using them.

It's your program – you decide. Personally, I'd try to find some clever way to noop the arrow key in the opposite direction, even if it costs a few bytes.

lydell avatar Jun 29 '16 05:06 lydell