Snake Game Help

i have some problem in changing Direction of my snake,how to change this code,because of using cout<<"***"; i have this problem,i know i have to save every location of snake going but i dont know how can i do this,i want to change this in this way,when i hit a key it change direction and goes down truely,not in this way

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
#include <vector>
#include <conio.h>
#include <windows.h>
#include <stdio.h>

using namespace std;

void gotoxy(int eex, int eey)
{
    COORD coord;
    coord.X = eex;
    coord.Y = eey;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}

int main()
{

    int x=0,y=10,lx=0,ly=0;
    for(int i=10;;i++)
    {
        gotoxy(i,y);
        cout<<"***";
        Sleep(100);
        lx=i;
        ly=y;
        gotoxy(lx,ly);
        cout<<"   ";
        if(kbhit())
        {
            for(int j=ly;;j++)
            {
                gotoxy(lx,j);
                cout<<"***";
                Sleep(100);
                ly=j;
                gotoxy(lx,ly);
                cout<<"   ";
            }

        }
    }
    return 0;
} 
Topic archived. No new replies allowed.