ok i need to code a game that has a rows and cols place in an array with every 5th one be a + with every other one using a period like this
............... .....
............... .....
............... .....
............... .....
....+.........+ .....
............... .....
............... .....
............... .....
............... .....
....+.........+ .....
i can get that layout using loops but i cant figure out how to store it as an array. There are two global constants GRID_WIDTH and GRID_HEIGHT. how exactly could i store it so that i could transfer it to another module? so that when a buoy is place i can change the char in that array to the new char? here is that part of the code even though idk if it will help much
oh the numbers are in there so you can tell where the buoy is place there are numbers on top that i didnt figure were important
............... .....
............... .....
............... .....
............... .....
....+.........+ .....
............... .....
............... .....
............... .....
............... .....
....+.........+ .....
i can get that layout using loops but i cant figure out how to store it as an array. There are two global constants GRID_WIDTH and GRID_HEIGHT. how exactly could i store it so that i could transfer it to another module? so that when a buoy is place i can change the char in that array to the new char? here is that part of the code even though idk if it will help much
Code:
for (int j = 1; j <= GRID_HEIGHT; j++)
{
if(GRID_HEIGHT < 1)
{
cout << setw(1) << j;
}
else
{
cout << setw(2) << j;
}
if(j % 5)
{
for(int y = 1; y <= GRID_WIDTH; y++)
{
cout << EMPTY_SPACE;
}
}
else
{
for(i = 1; i <= GRID_WIDTH; i++)
{
if(i % 5)
{
cout << EMPTY_SPACE;
}
else
{
cout << INTERSECTION;
}
}//end for
}//end else
if(GRID_HEIGHT < 10)
{
cout << setw(1) << j;
}
else
{
cout << setw(2) << j;
}
cout << endl;
}
Comment