Help with roguelike Game

I have a function that is supposed to check whether or not the character can pass through a point on the map. I have the exact same code as someone has in their tutorial, but I can still pass through the walls.

Here is my DrawMap() code.

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
  while (gamerunning)
	{

		DrawMap();

		
		console.Position(playerX, playerY);
		console << "@";
		

		KEYPRESS KeyPress = console.WaitForKeypress();

		

		switch (KeyPress.eCode)
		{

		case CONSOLE_KEY_UP:
			if (isPassable(playerX, playerY - 1))
				playerY--;

			break;

		case CONSOLE_KEY_DOWN:
			if (isPassable(playerX, playerY + 1))
				playerY++;
			break;

		case CONSOLE_KEY_LEFT:
			if (isPassable(playerX - 1, playerY))
				playerX--;
			break;

		case CONSOLE_KEY_RIGHT:
			if (isPassable(playerX + 1, playerY))
				playerX++;
			break;
		}

	}


Now, here is my isPassable() function.

1
2
3
4
5
6
7
8
9
10
11
12
13
bool isPassable(int x, int y)
{

	int value = map[height][width];

	

	if (value == floor)
		return true;

	return false;

}


If you need more code, then please just tell me.
bool isPassable(int x, int y)
{

int value = map[height][width]


map[height][width] is probably out of bounds. Did you mean to do map[y][x]?
Topic archived. No new replies allowed.