r/WebGames 3d ago

Classic Snake Game - Yes it is just snake. But there is more...

https://nightmarius.com/snake
0 Upvotes

14 comments sorted by

2

u/mr-english 3d ago edited 2d ago

Keyboard controls are laggy and unresponsive.

1

u/Nightmarius 3d ago

Sorry you feel that way. What makes it feel unresponsive?

2

u/mr-english 3d ago

For instance, to do a tight U-turn in snake games typically you can press two movement buttons one after another in rapid succession... like if your snake is travelling upwards you can press left|down so your head is now travelling downwards in the column directly to the left of your body.

In your version though, half the time this kills you for some reason. I'm guessing because your keyboard control logic registers the first keypress, i.e. left, but BEFORE it has actually moved you left... So now the game logic thinks "the snake's head is travelling left" (even though it hasn't moved) which then allows it to accept the second keypress, down, but again before it has actually actioned the first keypress and moved you left... so in effect it lets you press down while you're travelling up, or left while travelling right, etc.

That's just a guess though.

1

u/Nightmarius 3d ago

Yes that could indeed be a bug in the code. I will try to fix it. Thanks for the feedback.

1

u/Nightmarius 2d ago

Quick succesive direction changes should now work!

1

u/mr-english 2d ago

I just tried it and it works! Good work.

Although FYI the cursor key controls scrolled the page up and down (Firefox 137.0)

1

u/Nightmarius 2d ago

Nice! Thank you. Yes I am aware, maybe i should not have readded the arrow keys😅

1

u/jnelly 2d ago

worked fine for me once speed is 8 or higher.

1

u/gulmohor11 3d ago

Not supported on mobile. Why not add arrow buttons on screen so that it can be played on touch screen devices as well. Example https://playmangogames.com/Maze/maze.html

1

u/Nightmarius 3d ago

Thanks for the suggestion. I will look into it. Btw I also have a maze game https://nightmarius.com/maze

1

u/gulmohor11 3d ago

Nice. I played it. It's cool.

2

u/Nightmarius 2d ago

I added the buttons for mobile!

1

u/gulmohor11 2d ago

Great. I was able to go up to 10 fruits. Also why would a snake eat fruits? 😅

1

u/Nightmarius 2d ago

Nice! To get drunk maybe...