if (playerturn == 1) {
currentpos1 = startpos1 + dicetotal;
prevpos1 = currentpos1 - dicetotal;
} else {
currentpos2 = startpos2 + dicetotal;
prevpos2 = currentpos2 - dicetotal;
}
I know this is a slight duplicate of other questions, but I still didn't understand the answers. This is for a monopoly board game, which can have upto 6 players. I want to clean up the code, because the only thing that changes is the last part of the variable.
Currentpos(i), Prevpos(i), Startpos(i) are variable names. So how would I concatenate a variable into a variable name?