Skip to content
Permalink
8b01d786bb
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
89 lines (72 sloc) 1.9 KB
#include<stdio.h>
#include<conio.h>
#include<iostream>
#include<cstdlib>
#include<stdlib.h>
#include<windows.h>
using namespace std;
COORD coord={10,10}; // this is global variable
/*center of axis is set to the top left cornor of the screen*/
void gotoxy(int x, int y)
{
coord.X=x;
coord.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}
int main()
{
int x=30;
int y=10;
char ch;
gotoxy(x,y);
printf("@");
bool control=true;
while (control)
{
ch=_getch();
string clearScreenString(1,'\n');
string clearScreenString1(1,'\n');
if((int)ch==97||(int)ch==64||(int)ch==17)
{
x--;
}
else if((int)ch==115||(int)ch==83||(int)ch==18)
{
y++;
}
else if((int)ch==100||(int)ch==68||(int)ch==19)
{
x++;
}
else if((int)ch==119||(int)ch==87||(int)ch==20)
{
y--;
}
else
{
char sure;
cout<<"ARE YOU SURE TO EXIT(y/n)"<<endl;
cin >> sure;
if((int)sure==121 ||(int)sure==89)
{
control=false;
exit(0);
}
else if((int)sure==110||(int)sure==79)
{
system("cls");
cout<<"use controls";
continue;
}
else
{
cout<<"couinvalid input";
}
}
gotoxy(x,y);
printf("@");
cout<<clearScreenString;
cout<<clearScreenString1;
}
return 0;
}