polaryeti Posted January 11, 2023 Share Posted January 11, 2023 https://codepen.io/pelko/pen/jOpBmPN Here's the full code. snakeArr.unshift({ x: snakeArr[0].x + inputDir.x, y: snakeArr[0].y + inputDir.y }) This is the code to increase the size of snake once it collides with food. The code above it is working. foodSound.play(); Similarly, the code below it is working //change food location let a = 2; b = 16; food = { x: Math.round(a + (b - a) * Math.random()), y: Math.round(a + (b - a) * Math.random()) } What went wrong? Please help me fix the issue. There are no errors in console. Quote Link to comment https://forums.phpfreaks.com/topic/315781-why-is-my-snake-not-increasing-after-eating-food/ Share on other sites More sharing options...
Solution polaryeti Posted January 11, 2023 Author Solution Share Posted January 11, 2023 This issue has been fixed, I forgot to add CSS class to snake. Quote Link to comment https://forums.phpfreaks.com/topic/315781-why-is-my-snake-not-increasing-after-eating-food/#findComment-1604525 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.