How to make a tail and make my snake move automatic in C#

using System;
using System.Collections.Generic;
using System.Diagnostics;

namespace Snake
{
class Program
{
struct SnakeHead
{

        public SnakeHead(int x, int y)
        {
            X = x;
            Y = y;
        }

        public int X { get; set; }
        public int Y { get; set; }
    }

    static void startsida()
    {
        Console.WriteLine("||==================================)||");
        Console.WriteLine("||----------------------------------)||");
        Console.WriteLine("   tryck enter för att starta snake");
        Console.WriteLine("||----------------------------------)||");
        Console.WriteLine("||===================================||");
        string input = (Console.ReadLine());

    }
    static void Main(string[] args)
    {
        startsida();
        int[] map = { 6, 13 };

        SnakeHead sH = new SnakeHead(4, 4);


        while (true)
        {
            Console.Clear();

            for (int y = 0; y <= map[0]; y++)
            {
                for (int x = 0; x <= map[1]; x++)
                {
                    if (y == sH.Y && x == sH.X) Console.Write(" = ");
                    else Console.Write(" . ");
                }
                Console.WriteLine();


            }



            while (true)
            {

                var key = Console.ReadKey(true);


                if (key.Key == ConsoleKey.LeftArrow)
                {
                    if ((sH.X - 1) >= 0)
                    {
                        sH.X--;
                        break;
                    }

                }

                if (key.Key == ConsoleKey.RightArrow)
                {
                    if ((sH.X + 1) <= map[1])
                    {
                        sH.X++;
                        break;
                    }

                }

I’m trying to do a snake game but I don’t know how to make the tail and how to make my snake move automatic

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.