Urgent Debugging Assistance

I am in dire need of assistance with a bug in my programme. this one bug is the only thing stopping me from handing in my assignment. My programme is a basic rpg game. where the user moves around a map and encounters scenarios and battles. however the moving around the map function that I have used isn't working correctly. The issue is that when the user presses an arrow key. they move one space, and then can no longer move in that direction any further, and when a different arrow key is pressed a second character icon(*) appears and no further input for movement is registered. I have changed my code multiple times and tested and I still cant seem to get it to work. it compiles perfectly fine. I just possibly need a second pair of eyes to check my code and see if there's anything I've missed which is making the bug

the following code is the original that didn't work

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
 #ifndef MAP_HPP
#define MAP_HPP

#include <iostream>
#include "windows.h"
#include "character_stats.hpp"

void map(){
	

	using namespace std;
 // x is a wall //* is the character
char map [20][60] = {
           "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
           "x* xx     xxxxxxxxx  xxxxxxxxxxxxxxxxxxxxxxxxxxxx   xxxx",
           "x  xx  x  x   xxxxx  xxxxxxxx                       xxxx",
           "x  xxxxx  x                    xxxxxxxxx  xxxxxxxxxxxxxx",
           "x  xxxxx  xxxxxxxxxxxxxxxxxxx  xxxxxxxxx  xxxxxxxxxxxxxx",
           "x                                                    xxx",
           "x  xxx  xxxxxxxxxxxxxx  xxxxxxxxxxx  xxx  xxxxxxxxxxxxxx",
           "x  xxx  xxx             x         x  xxx  xxxxxxxxxxxxxx",
           "x  xxx  xxxxxxx  xxxxxxxx  xxxxxxxx  xxx          xxxxxx",
           "x  xxx  xxx       xxxxxxx         x  xxx          xxxxxx",
           "x  xxxxxxxx       xxxxxxx  xxxxxxxx  xxx          xxxxxx",
           "x                 xxxxxxx         x  xxxxxx  xxxxxxxxxxx",
           "x  xxxxxxxxxxxxxxxxxxxxxx  xxxxxxxx  xxxxxx            x",
           "x  x                                 xxxxxx  xxx   x   x",
           "x  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  xxxxxx  xxx   x   x",
           "x  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  xxxxxx  xxx xxxxxxx",
           "x                                    xxx               x",
	   "x  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
           "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 
};
           
           
while(HP>0){
	system("cls");
	for(int display=0; display<20; display++){
	cout << map[display] <<endl;
}
        system("pause>0");
        
	int x=1;
	int y=1;
	if(GetAsyncKeyState(VK_DOWN)){ // move down
	int y2 = y+1;
	if(map[y2][x] == ' '){
	    map[y][x] =' ';
	    y++;
	    map[y][x] = '*';}}
	    
	if(GetAsyncKeyState(VK_UP)){  // move up
	int y2 = y-1;
	if(map[y2][x] == ' '){
	    map[y][x] =' ';
	    y--;
	    map[y][x] = '*';}}
	    
	if(GetAsyncKeyState(VK_RIGHT)){ // move right
	int x2 = x+1;
	if(map[y][x2] == ' '){
	    map[y][x] =' ';
	    x++;
	    map[y][x] = '*';}}
	    
	if(GetAsyncKeyState(VK_LEFT)){  // move left
	int x2 = x-1;
	if(map[y][x2] == ' '){
	    map[y][x] =' ';
	    x--;
	    map[y][x] = '*';}}
}
Where is loop around GetAsyncKeyState? You probably want to move } from line 40 to 71-72.
My god of course!! feel like such an idiot. tired eyes make for hard debugging.
thanks very much its sorted now.
Topic archived. No new replies allowed.