I need help with My commands

The commands that I want the user to put in to make the @ sign move is not working. If someone could help me out it would be much appreciated

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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
 #include <iostream>
#include <windows.h>
#include <string>
#include <sstream>

using namespace std;


char map[20] [40] = {"#####################################",
					 "#   #   #   #   #   #   #   #   #   #",
					 "#   #   #   #   #   #   #   #   #   #",
					 "#   #   #   #   #   #   #   #   #   #",
					 "#####################################",
					 "#####################################",
					 "#   #   #   #   #   #   #   #   #   #",
					 "#   #   #   #   #   #   #   #   #   #",
					 "#   #   #   #   #   #   #   #   #   #",
					 "#####################################",
					 "#####################################",
					 "#   #   #   #   #   #   #   #   #   #",
					 "#   #   #   #   #   #   #   #   #   #",
					 "#   #   #   #   #   #   #   #   #   #",
					 "#####################################",
					 "#####################################",
					 "#   #   #   #   #   #   #   #   #   #",
					 "# @ #   #   #   #   #   #   #   #   #",
					 "#   #   #   #   #   #   #   #   #   #",
					 "#####################################"};
int Gamespeed = 5;
int Level = 1;
bool stopgame = false;
int hp = 10;
int MaxHp = 10;
int mp = 15;
int MaxMana = 15;
int choice; 
int Up = "Up";
int Down = "Down";
int Right = "Right";
int Left = "Left";
int main()
{
	while(stopgame == false && Level == 1)
	{
		system("cls");

		for (int y = 0; y < 20; y++)
		{
			cout << map[y] << endl;
		}
		cout << "Which Dorection would you like to go?\n";
		cin >> choice;
		for (int y = 0; y < 20; y++)
		{
			for (int x = 0; x < 40; x++)
			{
				switch (map[y][x])
				{
				case'@':
					{
							if (choice == Up)
							{
								int y2 = (y-1);
								switch(map[y2][x])
								{
								case ' ':
									{
										map[y][x] = ' ';
										y -= 1;
										map[y2][x] = '@';
									}break;
								}
							} //if (choice == Up)
							if(choice == Down)
							{
								int y2 = (y+1);
								switch(map[y2][x])
								{
								case ' ':
									{
										map[y][x] = ' ';
										y += 1;
										map[y2][x] = '@';
									}break;
								}
							} //if(choice == Down)
							if(choice == Right)
							{
								int x2 = (x+1);
								switch(map[y][x2])
								{
								case ' ':
									{
										map[y][x] = ' ';
										x += 1;
										map[y][x2] = '@';
									}break;
								}
							} //if(choice == Right)
							if(choice == Left)
							{
								int x2 = (x-1);
								switch(map[y][x2])
								{
								case ' ':
									{
										map[y][x] = ' ';
										x -= 1;
										map[y][x2] = '@';
									}break;
								}
							} //if(choice == Left)
					}break; // case'@':

				} // switch (map[y][x])

			} // for (int x = 0; x < 40; x++)

		} // for (int y = 0; y < 20; y++)

	} // while(stopgame == false && Level == 1)

return 0;
} // int main 
closed account (j3Rz8vqX)
Change variables on line 36 - 40 to string type.

It will be case sensitive, as in you will need to input the strings exactly the same to be equivalent and produce a move.
Last edited on
im nit sure what you mean]

Dput means these:

1
2
3
4
int Up = "Up";
int Down = "Down";
int Right = "Right";
int Left = "Left";


You are assigning integers with strings.

Topic archived. No new replies allowed.