public void Update() { if (this.Body.Count == 0) { return; } Coordinates lastBodyPartCoordinates = new Coordinates(this.Body[0].Position.X, this.Body[0].Position.Y); this.UpdateHead(); if (this.Body.Count == 1) { return; } this.UpdateTail(lastBodyPartCoordinates); }
private char SnakeBodyCharacter(Coordinates position) { return position == SnakeHead ? SnakeHeadCharacter() : '@'; }
private void UpdateTail(Coordinates lastBodyPartCoordinates) { for (int index = 1; index < this.Body.Count; index++) { Coordinates currentBodyPartCoordinates = new Coordinates(this.Body[index].Position.X, this.Body[index].Position.Y); this.Body[index].Position.X = lastBodyPartCoordinates.X; this.Body[index].Position.Y = lastBodyPartCoordinates.Y; lastBodyPartCoordinates = currentBodyPartCoordinates; } }