Vote count:
0
I am creating a Battleship game for a class and have a grid of picture boxes layed out as the board.
I am wondering if there is any way I can refer to the picture box as a variable so I can iterate through them using a loop.
Naming scheme is pA1-pA10 for column1, pB1-pB10 for column2 etc through column 10.
What I am needing to do is figure out a way to put this function in a loop so it can iterate through the list without having to have this code for each picture box.
This code is what is used to check what value is stored in the array and load the correct image into the picturebox.
if (pIsShip(0, 0)=='s')
{
pA1->Load("Ship.png");
}
else if (pIsShip(0, 0) == 'w')
{
pA1->Load("Water.png");
}
else if (pIsShip(0, 0) == 'h')
{
pA1->Load("Hit.png");
}
else if (pIsShip(0, 0) == 'm')
{
pA1->Load("Miss.png");
}
asked 1 min ago
Visual C++ picturebox naming with a variable
Aucun commentaire:
Enregistrer un commentaire