Why is my snake not increasing after eating food?

Joined
Dec 11, 2022
Messages
11
Reaction score
1
https://codepen.io/pelko/pen/jOpBmPN
Here's the full code.
JavaScript:
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 and below it, sound play when food is eaten and changing food location when food is eaten are working(sound play won't work on codepen).
What's the problem. Please help to fix the issue and understand it as well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top