Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualYoubar

Posted 06 December 2012 - 09:27 PM

Oh, I understand now, thanks. Posted Image

EDIT:
I'm getting an error in this code:

#include <iostream>
using namespace std;
int map[5][5] =
{
1, 1, 3, 1, 1,
1, 0, 0, 0, 1,
1, 0, 2, 0, 1,
1, 0, 0, 0, 1,
1, 1, 1, 1, 1
};
int column = 0;
int row = 0;
int x = 2;
int y = 2;
char dir = 'x';
bool game_ended = false;
void stop()
{
cout << endl;
system("PAUSE");
}
void cls()
{
system("CLS");
}
void print_map()
{
for (row = 0; row < 5; ++row)
{
  for (column = 0; column < 5; ++column)
  {
   cout << map[row][column] << ' ';
  }
  cout << endl;
}
}
void redraw()
{
cls();
print_map();
}
int main()
{
print_map();
cout << "What direction would you like to go in?" << endl;
cin >> dir;
while (game_ended != true)
{
  if (dir == 'w')
  {
   map[x][y] = 0;
   x--;
   map[x][y] = 2;
   redraw();
  }
}
stop();
}

I get an error that says:

Unhandled exception at 0x00411ced in Turn-based RPG.exe: 0xC0000005: Access violation writing location 0x0041aff4.

I am guessing this is due to the array. How would I fix this?

#2Youbar

Posted 06 December 2012 - 09:25 PM

Oh, I understand now, thanks. Posted Image

EDIT:
I'm getting an error in this code:

#include <iostream>
using namespace std;
int map[5][5] =
{
1, 1, 3, 1, 1,
1, 0, 0, 0, 1,
1, 0, 2, 0, 1,
1, 0, 0, 0, 1,
1, 1, 1, 1, 1
};
int column = 0;
int row = 0;
int x = 2;
int y = 2;
char dir = 'x';
bool game_ended = false;
void stop()
{
cout << endl;
system("PAUSE");
}
void cls()
{
system("CLS");
}
void print_map()
{
for (row = 0; row < 5; ++row)
{
  for (column = 0; column < 5; ++column)
  {
   cout << map[row][column] << ' ';
  }
  cout << endl;
}
}
void redraw()
{
cls();
print_map();
}
int main()
{
print_map();
cout << "What direction would you like to go in?" << endl;
cin >> dir;
while (game_ended != true)
{
  if (dir == 'w')
  {
   map[x][y] = 0;
   x--;
   map[x][y] = 2;
   redraw();
  }
}
stop();
}

I get an error that says:
Unhandled exception at 0x00411ced in Turn-based RPG.exe: 0xC0000005: Access violation writing location 0x0041aff4.

#1Youbar

Posted 06 December 2012 - 09:20 PM

Oh, I understand now, thanks. :)

PARTNERS