some one help me plz
m making snake game and i have used system("cls")
command in all the functions which i have made so when i call any function it will clear the screan and only single star is printed now i want to know how else i do my work this is my first phase of the game plzzz help me.
i want to complete it myself not by copying so thank in advance.
my code is the place which i have comment out are used to generate the food for the snake but system("cls")......
#include<iostream>
#include<conio.h>
#include<stdlib.h>
#include<windows.h>
using namespace std;
int x=25,y=10;
void gotoxy(int x, int y)
{
COORD coord;
coord.X = x; coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
void move_up()
{
while(!kbhit())
{
gotoxy(x,y);
cout<<"*";
Sleep(100);
system("cls");
y--;
}
}
void move_down()
{
while(!kbhit())
{
gotoxy(x,y);
cout<<"*";
Sleep(100);
system("cls");
y++;
}
}
void move_right()
{
while(!kbhit())
{
gotoxy(x,y);
cout<<"*";
Sleep(100);
system("cls");
x++;
}
}
void move_left()
{
while(!kbhit())
{
gotoxy(x,y);
cout<<"*";
Sleep(100);
system("cls");
x--;
}
}
/*
void random_number(int a,int b)
{
int chek=0;
chek=rand()%10;
a=x+chek;
b=y+chek;
gotoxy(a,b);
cout<<"+";
}
*/
int main()
{
char ch;
// int a=0,b=0,chek,i=1;
/* chek=rand()%10;
a=x+chek;
b=y+chek;
random_number(a,b);
*/
while(1)
{
move_right();
if(kbhit())
{
ch=getch();
if(ch=='w')
{
move_up();
}
else
{
if(ch=='a')
{
move_left();
}
else
{
if(ch=='d')
{
move_right();
}
else
{
if(ch=='s')
{
move_down();
}
}
}
}
}
/*
if(a==x)
{
random_number(a,b);
}*/
}
return 0;
}