Why is my snake not increasing after eating food?

In summary, there are several possible reasons for a snake not increasing in size after eating, including not actually consuming the food, lack of proper nutrition, health issues, or a shedding phase. The amount of size increase after a meal varies depending on factors such as the type and size of the snake and the prey it consumes. A diet lacking in essential nutrients can also hinder a snake's growth. It is normal for snakes to have periods of growth and no growth, and the best way to track growth is by measuring length and weight. If concerned, consult with a reptile veterinarian for professional advice.
  • #1
shivajikobardan
674
54
TL;DR Summary
snake not increasing after eating food.

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.
 
Technology news on Phys.org
  • #2
This issue has been fixed, I forgot to add CSS class to snake.
 
  • Like
Likes jedishrfu

Similar threads

  • Programming and Computer Science
Replies
14
Views
2K
  • Programming and Computer Science
Replies
11
Views
1K
  • Programming and Computer Science
Replies
2
Views
75
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
5
Views
3K
  • Programming and Computer Science
Replies
9
Views
1K
Replies
63
Views
3K
  • Programming and Computer Science
2
Replies
39
Views
3K
  • Programming and Computer Science
Replies
33
Views
6K
Replies
17
Views
2K
Back
Top