I think you should pay closer attention to what is a row and what is a column.
You defined Board[ROWS][COLUMNS]
you have x going from 0 to COLUMNS, and y going from 0 to ROWS. Then you use Board[x][y]...Since rows != columns you run into problems.
I find it better to name my variables 'rows' and 'columns' rather than 'x' and 'y' as it helps keep in mind what is what.
here is what I did to get the code working:
CODE
#include <iostream>
using namespace std;
//defining that the rows equal 21 and the columns equal 16
#define ROWS 21
#define COLUMNS 16
void Board( double[ROWS][COLUMNS] ); //function declaration
// this is my game board
void draw(char Board[ROWS][COLUMNS])
{
int x,y;
for( x=0; x<COLUMNS;x++)
{
for(y=0; y<ROWS; y++)
{
std::cout << "--";
}
std::cout << "-" <<std::endl;
for (y=0;y<ROWS; y++)
{
std::cout << "|" << Board[y][x];
}
std::cout << "|" <<std::endl;
}
for(y=0; y <ROWS;y++)
{
std::cout << "--";
}
std::cout << "-" << std::endl;
}
// main function for my moving ships TEST
int main()
{
int x, y;
char Board[ROWS][COLUMNS];
for (x=0; x<COLUMNS; ++x) {
for (y=0;y<ROWS;++y) {
Board[y][x]='.';
}
}
// drawing the board as a blank board
for(x=1; x<COLUMNS; ++x)
Board[0][x]='A'+x-1;
for(y=1; y<ROWS; ++y)
Board[y][0]='A'+y-1;
//draw(Board);
// testing the position of a single Torpedo Boat (#)
x=2;
y=3;
Board[y][x]='#'; //symbol of the ship
char direction;
while(1)
{
draw(Board);
cout << "\nEnter a letter to move (U)p, (D)own, (L)eft, or (R)ight or press (E) to Exit: ";
cin >> direction;
switch (direction)
{
case 'U': case 'u': Board[y][x]=' '; x--; Board[y][x]='#';
break;
case 'D': case 'd': Board[y][x]=' '; x++; Board[y][x]='#';
break;
case 'L': case 'l': Board[y][x]=' '; y--; Board[y][x]='#';
break;
case 'R': case 'r': Board[y][x]=' '; y++; Board[y][x]='#';
break;
case 'E': case 'e':
exit(0);
break;
}
}
return 0;
}
Note that I didn't put a lot of thought into the logic, I just made it work.