我正在尝试在 OpenGL 中制作游戏并想移动相机。我已经使用以下代码完成了它:
t.calculations(&t1, 5.54, 1.54, 10, 10, 1);
t.calculations(&t2, 5.54, 1.54, 10, 10, 1);
t.calculations(&t3, 5.54, 1.54, 10, 10, 1);
t.calculations(&t4, 5.54, 1.54, 10, 10, 1);
t.calculations(&t5, 5.54, 1.54, 10, 10, 1);
t.calculations(&t6, 5.54, 1.54, 10, 10, 1);
t.calculations(&t7, 5.54, 1.54, 10, 10, 1);
t.calculations(&t8, 5.54, 1.54, 10, 10, 1);
t.calculations(&t9, 5.54, 1.54, 10, 10, 1);
t.calculations(&t10, 5.54, 1.54, 10, 10 ,1);
t.calculations(&t11, 5.54, 1.54, 10, 10, 1);
t.calculations(&t12, 5.54, 1.54, 10, 10, 1);
t.calculations(&t13, 5.54, 1.54, 10, 10, 1);
t.calculations(&t14, 5.54, 1.54, 10, 10, 1);
t.calculations(&t15, 5.54, 1.54, 10, 10, 1);
t.calculations(&t16, 5.54, 1.54, 10, 10, 1);
t.calculations(&t17, 5.54, 1.54, 10, 10, 1);
t.calculations(&t18, 5.54, 1.54, 10, 10, 1);
但是正如你所看到的,这看起来像是代码的过度重复。我曾尝试使用以下方法而不是上述方法:
for (int i = 1; i < 19; i++) {
t.calculations(&t+i, 5.54, 1.54, 10, 10, 1);
}
但它不起作用。谁能告诉我一个替代解决方案?