/// <summary> /// Inserts a new piece to the snake's body /// </summary> private void GrowSnake() { double xPos = GameObjects[mTailIndex].Transformation.Position.X; double yPos = GameObjects[mTailIndex].Transformation.Position.Y; double rotation = GameObjects[mTailIndex].Transformation.RotationAngle; SnakeComponent piece = new SnakeComponent(SNAKE_WIDTH, SNAKE_HEIGHT, TextureManager.GetTexture("Assets\\Textures\\Snake\\snake_body.png"), new Point(xPos, yPos), rotation, new Point(1.0, 1.0)); AddGameObject(piece); }
/// <summary> /// Creates the snake /// </summary> private void CreateSnake() { SnakeComponent head = new SnakeComponent(SNAKE_WIDTH, SNAKE_HEIGHT, TextureManager.GetTexture("Assets\\Textures\\Snake\\snake_head.png"), new Point(80, 104), 0, new Point(1.0, 1.0)); SnakeComponent tail = new SnakeComponent(SNAKE_WIDTH, SNAKE_HEIGHT, TextureManager.GetTexture("Assets\\Textures\\Snake\\snake_tail.png"), new Point(80, 64), 0, new Point(1.0, 1.0)); GameObjects.Add(tail); mTailIndex = GameObjects.Count - 1; GameObjects.Add(head); GrowSnake(); }