Controls seem slightly delayed but more due to the fact the snake needs to move in the grid of blocks instead of changing the second you push the button… might be better if I calculate the turn based on when the snake is between block grids rather then just entered the block grid, I might update that when I have more time just to check.
I took a peak at the code and appreciated all the comments . I’m learning Javascript myself and found all the comments helpful to follow along with how the program was working.
Thanks. And yep, thats basically it. At each interval, it adds a new head to the array based on direction/speed, and deletes the tail most block, checks for tail/wall/food hits, and then redraw. The challenge is keeping the snake on the grid instead of just turning the instant a direction key is pressed. Thats what causes the delay because when arrow is pressed but the snake isn’t lined up yet, a few more frames has to pass before the direction change occurs. Also learned to queue direction changes because if someone hit keys fast enough it could bypass checks if multiple direction changes happen between frame refreshes. It was fun. Next is a block breakout game.