Move inside of an array?

So far this sorta...ehh works haha. I mean not really but when I move down i can only move down once then the character reappears... Btw don't ask about the face haha!
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
64
65
66
67
68
69
70
71
72
73
74
75
  #include <iostream>
#include <Windows.h>

using std::cin;
using std::endl;
using std::cout;

char map[12][16]{
	"###############",
	"#@            #",
	"#             #",
	"#             #",
	"#             #",
	"#             #",
	"#             #",
	"#             #",
	"#             #",
	"#             #",
	"#             #",
	"###############",

};

char face[5][10]{
	"|-------|",
	"| * > * |",
	"| /---\ |",
	"|/-----\|",
	"........."
};

int main() {
	cout << "Please press an arrow key!" << endl;
	cout << "Press ESC to exit this test" << endl;
	int x2 = 1;
	int y2 = 1;
	int prevx;
	int prevy;
	char player;
	player = map[y2][x2];
	char done;
	Sleep(1000);
	while (GetAsyncKeyState(VK_ESCAPE) == 0) {
		Sleep(100);
		cout.flush();
		system("cls");
		for (int y = 0; y < 12; y++)
			cout << map[y] << endl;
		if (GetAsyncKeyState(VK_UP) != 0) {
			cout << "You are pressing the up key" << endl;
			map[y2 - 1][x2] = map[y2][x2];
			Sleep(100);
		}
		else if (GetAsyncKeyState(VK_DOWN) != 0) {
			cout << "You are pressing the down key" << endl;
			map[y2][x2] = map[y2 + 1][x2];
			map[y2][x2] = '@';
			Sleep(100);
		}
		else if (GetAsyncKeyState(VK_RIGHT) != 0) {
			cout << "You are pressing the right key" << endl;
			map[y2][x2 + 1] = map[y2][x2];
			Sleep(100);
		}
		else if (GetAsyncKeyState(VK_LEFT) != 0) {
			cout << "You are pressing the left key" << endl;
			map[y2][x2 - 1] = map[y2][x2];
			Sleep(100);
		}
		else
			continue;
	}		
	cout << "Thanks for trying!" << endl;
	cin >> done;
}
Never mind again solved it :D!
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include <iostream>
#include <Windows.h>

using std::cin;
using std::endl;
using std::cout;

char map[12][16]{
	"###############",
	"#@            #",
	"#             #",
	"#             #",
	"#             #",
	"#             #",
	"#             #",
	"#             #",
	"#             #",
	"#             #",
	"#             |",
	"###############"
};
char city[14][28]{
	"###########################",
	"#                         #",
	"#                         #",
	"#                         #",
	"#                         #",
	"#                         #",
	"#                         #",
	"#                         #",
	"#                         #",
	"#                  ########",
	"#                  #      #",
	"#                  |      #",
	"#                  #      #",
	"###########################",

};

char face[5][10]{
	"|-------|",
	"| * > * |",
	"| /---\ |",
	"|/-----\|",
	"........."
};

int main() {
	cout << "Please press an arrow key!" << endl;
	cout << "Press ESC to exit this test" << endl;
	int x2 = 1;
	int y2 = 1;
	char player;
	player = map[y2][x2];
	char done;
	char b;
	Sleep(1000);
	while (GetAsyncKeyState(VK_ESCAPE) == 0) {

		map[y2][x2] = '@';
		Sleep(100);
		cout.flush();
		system("cls");
		for (int y = 0; y < 12; y++)
			cout << map[y] << endl;
		if ((GetAsyncKeyState(VK_UP)) != 0 && (y2 != 1)) {
				cout << "You are pressing the up key" << endl;
				y2 -= 1;
				map[y2 + 1][x2] = ' ';
		}
		else if ((GetAsyncKeyState(VK_DOWN)) != 0 && (y2 != 10)) {
			cout << "You are pressing the down key" << endl;
			y2 += 1;
			map[y2 - 1][x2] = ' ';
		}
		else if ((GetAsyncKeyState(VK_RIGHT)) != 0 && (x2 != 13))  {
			cout << "You are pressing the right key" << endl;
			x2 += 1;
			map[y2][x2 - 1] = ' ';
		}
		else if ((GetAsyncKeyState(VK_LEFT)) != 0 && (x2 != 1)) {
			cout << "You are pressing the left key" << endl;
			x2 -= 1;
			map[y2][x2 + 1] = ' ';
		}
			else
				continue;
	}		
	cout << "Thanks for trying!" << endl;
	cin >> done;
}
Topic archived. No new replies allowed.