How do I create a 2d array and move the checkerpieces? I only need to move the pieces forward and not backwards. I have this so far:
int main(int argc, char const** argv)
{
const int MAX_ROW = 8;
const int MAX_COLUMN = 8;
// Create the main window that is 400 pixels wide and 400 pixels tall
sf::RenderWindow window(sf::VideoMode(400, 400), "Checkers");
for (int i = 0; i < MAX_ROW; i++) { //loops through all the rows
for (int j = 0; j < MAX_COLUMN; j++) { //loops through all the columns
if (i % 2 == 0 && j % 2 == 0) { //Even locations of the board
int x = i * 50;
int y = j * 50;
sf::RectangleShape whitecolor(sf::Vector2f(50, 50)); //White rectangles for the board
whitecolor.setFillColor(sf::Color::White);
whitecolor.setPosition(sf::Vector2f(x, y));
vec.push_back(whitecolor);
}
//Odd locations of the board
if (i % 2 != 0 && j % 2 != 0) {
int x = i * 50;
int y = j * 50;
sf::RectangleShape whitecolor(sf::Vector2f(50, 50)); //White rectangles for the board
whitecolor.setFillColor(sf::Color::White);
whitecolor.setPosition(sf::Vector2f(x, y));
vec.push_back(whitecolor);
}
}
}
//First red checker row
for (int i = 0; i < MAX_ROW; i++) {
int x = (100 * i) - 50;
// Create a graphical text to display
////////////////// Leave This as is ////////////////////////////////////
while (window.isOpen())
{
// Process events
sf::Event event;
while (window.pollEvent(event))
{
// Close window: exit
if (event.type == sf::Event::Closed) {
window.close();
}