# How to make Snake Body in Snake Game?

I'm new in cocos2d and game dev. I'm still learning in game dev. My goal is to make one game like Doodle Grub. But problem is snake body. I wrote like following

-(void)update:(ccTime)delta
{
//NSLog(@"%f",[GameScence sharedGameScence].playerVelocity.y);

CGPoint tmp=self.position;
float tmprotation;

tmprotation=self.rotation;

}


snake is moving but problem is all of the body segments are same position when snake stop. And all of the body segments is so close and can't see segments like Doodle Grub. Any idea or Any suggestion ?

The Snake game is one of the most simplest yet addicting games built ever. I'll show you its implementation idea without code.

Consider an array containing n elements as in snake[n], where snake[0] is the head of the snake. Each element in the array snake i.e. for every snake[i] there should exist some mechanism to store its x and y coordinates.(I preferred arrays).We also need two variables which holds the x and y coordinates of the snake[0]. When the game loop begins, according to the desired direction, the snake[0] is moved accordingly.So since the snake[0] has moved to a different location what we have to do is 1.) assign into snake[1] the previous value(which we stored temporarily) of snake[0]. 2.) Iterate within a loop and change the values of snake[i] to snake[i-1] till snake[i] becomes equal to snake[n]. Feel free to ask me if you have more doubts. But I would recommend you first try these before asking someone a question.