-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnavigate.cpp
More file actions
63 lines (56 loc) · 812 Bytes
/
navigate.cpp
File metadata and controls
63 lines (56 loc) · 812 Bytes
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <ctype.h>
#include<windows.h>
void clrscr(void)
{
system("cls") ; //clear screen.
}
void gotoxy(short x, short y)
{
COORD pos = {x, y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
int main()
{
char name[]="Riddhi";
int px,py,ch=0,x=37,y=12;
gotoxy(x,y);
printf("%s",name);
while(ch!=27)//escape=27
{
ch=getch();
px=x;
py=y;
switch(ch)
{
case 'w':
case 'W':
y--;
break;
case 'a':
case 'A':
x--;
break;
case 's':
case 'S':
y++;
break;
case 'd':
case 'D':
x++;
break;
}
if(x<1)
x=74;
if(y<1)
y=25;
if(x>74)
x=1;
if(y>25)
y=1;
gotoxy(px,py); printf("%s"," ");
gotoxy(x,y); printf("%s",name);
}
}