The first thing we need to keep in mind is that the snake is of a variable length. The snake could be as short as one segment or as long as 100 segments (in theory—we won't get that long in our game). As we said during the design, the snake should be as autonomous as possible. With that in mind, let's look at the SNSnake.h
file to see what we need.
#import "SNSnakeSegment.h" @class SNPlayfieldLayer; @interface SNSnake : CCNode { SNPlayfieldLayer *parentLayer; // Parent layer NSMutableArray *snakebody; // Contains the snake NSInteger headRow; // Starting row for snake head NSInteger headColumn; // Starting col for snake head SnakeHeading _snakeDirection; // Direction facing float _snakeSpeed; // Current rate of movement } @property (nonatomic, retain) NSMutableArray *snakebody; @property (nonatomic, assign) SnakeHeading snakeDirection; @property (nonatomic, assign) float snakeSpeed; +(id) createWithLayer...