game rougelike

Hi I am trying to do a rogue like game but it's not working(as I expect it work)
The problem is when I want to move my avatar (the '@')it just doesn't do what it should do.

Can anyone tell me where I have gone wrong?

Many thanks!!

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
#include <iostream>		//basic input/output
#include <windows.h>	        //Sleep(), system()
#include <string>		//string variables .c_str()
#include <fstream>		//working with files, mainly .txt
#include <conio.h>		//_getch(), getline()
#include <vector>		//vectors ******not used for now******
#include <cmath>		//complex mathematical functions


using namespace std;	//basic I/O

void movement(char fmovement);	//forward declaration of the function

int main()		//main function
{

	string playerName, filename;
	int x, y, _x = 0, _y = 0;
	char area[256][256];
	long long levelHardness;
	char movement;

	system("color 1C");
	system("title Game by Nanyo");
	system("cls");

	cout << "Please enter your name: ";
	getline(cin, playerName);
	system("cls");
b:
	cout << "Enter difficulty (1, 2, 3): ";
	cin >> levelHardness;
	system("cls");


	if (levelHardness > 3)
	{
		cout << "Invalid input!";
		Sleep(1700);
		system("cls");
		goto b;
	}
	
	/****************************LEVEL ONE****************************/

	if (levelHardness == 1)
	{
		filename = "level1.txt";
		ifstream levels(filename.c_str());
		if (levels)
		{
			cout << "**************************LET THE GAMES BEGIN**************************\n\n";
			while (levels)
			{
				z:
				for (y = 0; y < 1; y++)
				{
					for (x = 0; x < 71; x++)
					{
						levels >> area[x][y];
						cout << area[x][y];
					}
					cout << endl;
				}
				movement = _getch();
				switch (movement)
				{
				case 'a':
					_x--;
					x = _x;
					break;
				case 's':
					_y++;
					y = _y;
					break;
				case 'd':
					_x++;
					x = _x;
					break;
				case 'w':
					_y--;
					y = _y;
					break;
				default:
					cout << "Invalid input\n";
				}
				goto z;
			}

		}
		if (!(levels))
		{
			perror("File info");
		}
		cout << endl;
	}
	system("pause");
	return 0;
}
Last edited on
Topic archived. No new replies allowed.