放置支柱
Placing of pillars
我正在尝试将柱子放在在这些数量的柱子之间交替的板上(我认为我没有正确解释),但例如在第 1 行它将有 9 个支柱,第 2 行它将有 8 个支柱。 我想尝试在嵌套的 for 循环中执行此操作,但不确定如何在块内进行代码。
目前我有这个:这是我的变量:
float PegPosX = -1.0f;
float PegYStartPos;
float PegPosY = 6.0f;
int Pegs = 0;
int PegsInRow = 8;
while(Pegs < NumPegs){
for (int row = 0; row < PegsInRow; ++row) {
int num_cols = (row % 2 == 0) ? 9 : 8;
PegPosY -= 0.5f;
for (int col = 0; col < num_cols; ++col){
PegPosX += 1.0f;
displayPegs[Pegs].PegPosition(PegPosX, PegPosY);
}
}
++Pegs;
}
for (int row = 0; row < num_rows; ++row) {
int num_cols = (row % 2 == 0) ? 9 : 8;
for (int col = 0; col < num_cols; ++col) {
placePillar(...);
}
}
相关文章:
- 没有找到相关文章